From f94faa2ebb722cd3422be194bef70088fcefa353 Mon Sep 17 00:00:00 2001 From: Hector Sanjuan Date: Tue, 23 Jan 2018 22:03:06 +0100 Subject: [PATCH] Fix #297: State unmarshal It seems we have problems deserializing on top of an already initialized state. License: MIT Signed-off-by: Hector Sanjuan --- state/mapstate/map_state.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/state/mapstate/map_state.go b/state/mapstate/map_state.go index f0a82e36..1301b9e2 100644 --- a/state/mapstate/map_state.go +++ b/state/mapstate/map_state.go @@ -12,6 +12,7 @@ import ( cid "github.com/ipfs/go-cid" logging "github.com/ipfs/go-log" + "github.com/ipfs/ipfs-cluster/api" ) @@ -150,10 +151,14 @@ func (st *MapState) Unmarshal(bs []byte) error { // snapshot is up to date buf := bytes.NewBuffer(bs[1:]) + newState := MapState{} dec := msgpack.Multicodec(msgpack.DefaultMsgpackHandle()).Decoder(buf) - err := dec.Decode(st) + err := dec.Decode(&newState) if err != nil { logger.Error(err) } + + st.PinMap = newState.PinMap + st.Version = newState.Version return err }