@cryptotaxi247 / kubo / commits / e6091be0c

pin: Return copies of pinned keys, of each type (direct/indirect/recursive)

Matt Bell committed Nov 19, 2014 at 00:53 UTC e6091be0c732d96bcebbb573f7978a6d6952ea17
2 files changed +20 -4
pin/indirect.go
+4
@@ -65,3 +65,7 @@ func (i *indirectPin) Decrement(k util.Key) {
65 func (i *indirectPin) HasKey(k util.Key) bool {
66 return i.blockset.HasKey(k)
67 }
68 +
69 +func (i *indirectPin) Set() set.BlockSet {
70 + return i.blockset
71 +}
pin/pin.go
+16 -4
@@ -33,7 +33,9 @@ type Pinner interface {
33 Unpin(util.Key, bool) error
34 Flush() error
35 GetManual() ManualPinner
36 - Set() set.BlockSet
36 + DirectKeys() []util.Key
37 + IndirectKeys() []util.Key
38 + RecursiveKeys() []util.Key
39 }
40
41 // ManualPinner is for manually editing the pin structure
@@ -208,9 +210,19 @@ func LoadPinner(d ds.Datastore, dserv mdag.DAGService) (Pinner, error) {
210 return p, nil
211 }
212
211 -// Set returns a blockset of directly pinned keys
212 -func (p *pinner) Set() set.BlockSet {
213 - return p.directPin
213 +// DirectKeys returns a slice containing the directly pinned keys
214 +func (p *pinner) DirectKeys() []util.Key {
215 + return p.directPin.GetKeys()
216 +}
217 +
218 +// IndirectKeys returns a slice containing the indirectly pinned keys
219 +func (p *pinner) IndirectKeys() []util.Key {
220 + return p.indirPin.Set().GetKeys()
221 +}
222 +
223 +// RecursiveKeys returns a slice containing the recursively pinned keys
224 +func (p *pinner) RecursiveKeys() []util.Key {
225 + return p.recursePin.GetKeys()
226 }
227
228 // Flush encodes and writes pinner keysets to the datastore