[#82] Return length check of serialized container
In #37 we've decided to remove length check, because smart contract would fail on casting `nil` value from storage to `[]byte` producing FAULT state. Apparently it does not fail, so we have to check length explicitly. Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
87fc4f5df7
commit
7d51688d2c
1 changed files with 8 additions and 1 deletions
|
@ -71,7 +71,14 @@ func (w *Wrapper) Get(cid *container.ID) (*container.Container, error) {
|
||||||
// ask RPC neo node to get serialized container
|
// ask RPC neo node to get serialized container
|
||||||
rpcAnswer, err := w.client.Get(args)
|
rpcAnswer, err := w.client.Get(args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(core.ErrNotFound, err.Error())
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// In #37 we've decided to remove length check, because smart contract would
|
||||||
|
// fail on casting `nil` value from storage to `[]byte` producing FAULT state.
|
||||||
|
// Apparently it does not fail, so we have to check length explicitly.
|
||||||
|
if len(rpcAnswer.Container()) == 0 {
|
||||||
|
return nil, core.ErrNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert serialized bytes into GRPC structure
|
// convert serialized bytes into GRPC structure
|
||||||
|
|
Loading…
Reference in a new issue