Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

Commit

Permalink
swarm/storage, swarm/shed: add support for persisting push tags
Browse files Browse the repository at this point in the history
  • Loading branch information
acud committed Mar 26, 2019
1 parent 2d20bf9 commit b828a34
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions swarm/shed/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type Item struct {
AccessTimestamp int64
StoreTimestamp int64
BinID uint64
Tags []uint64
}

// Merge is a helper method to construct a new
Expand Down
21 changes: 20 additions & 1 deletion swarm/storage/localstore/localstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,28 @@ func New(path string, baseKey []byte, o *Options) (db *DB, err error) {
return e, nil
},
EncodeValue: func(fields shed.Item) (value []byte, err error) {
return nil, nil
valueBuffer := []byte{}
buf := make([]byte, binary.MaxVarintLen64)

for _, v := range fields.Tags {
n := binary.PutUvarint(buf, v)
if n > 0 {
valueBuffer = append(valueBuffer, buf[:n]...)
}
}

return valueBuffer, nil
},
DecodeValue: func(keyItem shed.Item, value []byte) (e shed.Item, err error) {
for {
v, n := binary.Uvarint(value)
if n > 0 {
e.Tags = append(e.Tags, v)
} else {
break
}
value = value[n:]
}
return e, nil
},
})
Expand Down

0 comments on commit b828a34

Please sign in to comment.