Fix #297: State unmarshal
It seems we have problems deserializing on top of an already initialized state. License: MIT Signed-off-by: Hector Sanjuan <code@hector.link>
This commit is contained in:
parent
8e487cd880
commit
f94faa2ebb
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user