mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-29 01:12:24 +08:00
pin: Return copies of pinned keys, of each type (direct/indirect/recursive)
This commit is contained in:
@ -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
|
||||
}
|
||||
|
20
pin/pin.go
20
pin/pin.go
@ -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
|
||||
|
Reference in New Issue
Block a user