stackitem: support Null item (de-)serialization

It's binary representation contains just type (AnyT).
This commit is contained in:
Evgenii Stratonikov 2020-06-18 23:22:15 +03:00
parent c0e482fe6c
commit a980cac0b3

View file

@ -70,6 +70,8 @@ func serializeItemTo(item Item, w *io.BinWriter, seen map[Item]bool) {
serializeItemTo(t.Value().([]MapElement)[i].Key, w, seen) serializeItemTo(t.Value().([]MapElement)[i].Key, w, seen)
serializeItemTo(t.Value().([]MapElement)[i].Value, w, seen) serializeItemTo(t.Value().([]MapElement)[i].Value, w, seen)
} }
case Null:
w.WriteB(byte(AnyT))
} }
} }
@ -127,6 +129,8 @@ func DecodeBinaryStackItem(r *io.BinReader) Item {
m.Add(key, value) m.Add(key, value)
} }
return m return m
case AnyT:
return Null{}
default: default:
r.Err = errors.New("unknown type") r.Err = errors.New("unknown type")
return nil return nil