From b4c3ac80cb5b388b1d99d3f31648fb13483ca443 Mon Sep 17 00:00:00 2001 From: Anton Evangelatov Date: Wed, 7 Nov 2018 15:57:24 +0100 Subject: [PATCH] swarm/storage/feed: revert cursor changes --- swarm/storage/feed/feed.go | 2 ++ swarm/storage/feed/id.go | 8 +++++++- swarm/storage/feed/update.go | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/swarm/storage/feed/feed.go b/swarm/storage/feed/feed.go index 1a4598a3c8..b6ea665a6f 100644 --- a/swarm/storage/feed/feed.go +++ b/swarm/storage/feed/feed.go @@ -58,6 +58,7 @@ func (f *Feed) binaryPut(serializedData []byte) error { cursor += TopicLength copy(serializedData[cursor:cursor+common.AddressLength], f.User[:]) + cursor += common.AddressLength return nil } @@ -78,6 +79,7 @@ func (f *Feed) binaryGet(serializedData []byte) error { cursor += TopicLength copy(f.User[:], serializedData[cursor:cursor+common.AddressLength]) + cursor += common.AddressLength return nil } diff --git a/swarm/storage/feed/id.go b/swarm/storage/feed/id.go index 41d1596dfe..7e17743c11 100644 --- a/swarm/storage/feed/id.go +++ b/swarm/storage/feed/id.go @@ -71,6 +71,7 @@ func (u *ID) binaryPut(serializedData []byte) error { return err } copy(serializedData[cursor:cursor+lookup.EpochLength], epochBytes[:]) + cursor += lookup.EpochLength return nil } @@ -92,7 +93,12 @@ func (u *ID) binaryGet(serializedData []byte) error { } cursor += feedLength - return u.Epoch.UnmarshalBinary(serializedData[cursor : cursor+lookup.EpochLength]) + if err := u.Epoch.UnmarshalBinary(serializedData[cursor : cursor+lookup.EpochLength]); err != nil { + return err + } + cursor += lookup.EpochLength + + return nil } // FromValues deserializes this instance from a string key-value store diff --git a/swarm/storage/feed/update.go b/swarm/storage/feed/update.go index d2549e11ac..21c004ca42 100644 --- a/swarm/storage/feed/update.go +++ b/swarm/storage/feed/update.go @@ -75,6 +75,7 @@ func (r *Update) binaryPut(serializedData []byte) error { // add the data copy(serializedData[cursor:], r.data) + cursor += datalength return nil } @@ -105,12 +106,14 @@ func (r *Update) binaryGet(serializedData []byte) error { cursor += idLength data := serializedData[cursor : cursor+dataLength] + cursor += dataLength // now that all checks have passed, copy data into structure r.data = make([]byte, dataLength) copy(r.data, data) return nil + } // FromValues deserializes this instance from a string key-value store