Commit e6091be0 authored by Matt Bell's avatar Matt Bell

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

parent ae6f00d7
......@@ -65,3 +65,7 @@ func (i *indirectPin) Decrement(k util.Key) {
func (i *indirectPin) HasKey(k util.Key) bool {
return i.blockset.HasKey(k)
}
func (i *indirectPin) Set() set.BlockSet {
return i.blockset
}
......@@ -33,7 +33,9 @@ type Pinner interface {
Unpin(util.Key, bool) error
Flush() error
GetManual() ManualPinner
Set() set.BlockSet
DirectKeys() []util.Key
IndirectKeys() []util.Key
RecursiveKeys() []util.Key
}
// ManualPinner is for manually editing the pin structure
......@@ -208,9 +210,19 @@ func LoadPinner(d ds.Datastore, dserv mdag.DAGService) (Pinner, error) {
return p, nil
}
// Set returns a blockset of directly pinned keys
func (p *pinner) Set() set.BlockSet {
return p.directPin
// DirectKeys returns a slice containing the directly pinned keys
func (p *pinner) DirectKeys() []util.Key {
return p.directPin.GetKeys()
}
// IndirectKeys returns a slice containing the indirectly pinned keys
func (p *pinner) IndirectKeys() []util.Key {
return p.indirPin.Set().GetKeys()
}
// RecursiveKeys returns a slice containing the recursively pinned keys
func (p *pinner) RecursiveKeys() []util.Key {
return p.recursePin.GetKeys()
}
// Flush encodes and writes pinner keysets to the datastore
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment