swarm/storage/feed: revert cursor changes

This commit is contained in:
Anton Evangelatov 2018-11-07 15:57:24 +01:00
parent 9a847448c5
commit b4c3ac80cb
3 changed files with 12 additions and 1 deletions

View file

@ -58,6 +58,7 @@ func (f *Feed) binaryPut(serializedData []byte) error {
cursor += TopicLength cursor += TopicLength
copy(serializedData[cursor:cursor+common.AddressLength], f.User[:]) copy(serializedData[cursor:cursor+common.AddressLength], f.User[:])
cursor += common.AddressLength
return nil return nil
} }
@ -78,6 +79,7 @@ func (f *Feed) binaryGet(serializedData []byte) error {
cursor += TopicLength cursor += TopicLength
copy(f.User[:], serializedData[cursor:cursor+common.AddressLength]) copy(f.User[:], serializedData[cursor:cursor+common.AddressLength])
cursor += common.AddressLength
return nil return nil
} }

View file

@ -71,6 +71,7 @@ func (u *ID) binaryPut(serializedData []byte) error {
return err return err
} }
copy(serializedData[cursor:cursor+lookup.EpochLength], epochBytes[:]) copy(serializedData[cursor:cursor+lookup.EpochLength], epochBytes[:])
cursor += lookup.EpochLength
return nil return nil
} }
@ -92,7 +93,12 @@ func (u *ID) binaryGet(serializedData []byte) error {
} }
cursor += feedLength 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 // FromValues deserializes this instance from a string key-value store

View file

@ -75,6 +75,7 @@ func (r *Update) binaryPut(serializedData []byte) error {
// add the data // add the data
copy(serializedData[cursor:], r.data) copy(serializedData[cursor:], r.data)
cursor += datalength
return nil return nil
} }
@ -105,12 +106,14 @@ func (r *Update) binaryGet(serializedData []byte) error {
cursor += idLength cursor += idLength
data := serializedData[cursor : cursor+dataLength] data := serializedData[cursor : cursor+dataLength]
cursor += dataLength
// now that all checks have passed, copy data into structure // now that all checks have passed, copy data into structure
r.data = make([]byte, dataLength) r.data = make([]byte, dataLength)
copy(r.data, data) copy(r.data, data)
return nil return nil
} }
// FromValues deserializes this instance from a string key-value store // FromValues deserializes this instance from a string key-value store