feat: create provider store interface for use in hash query

This commit is contained in:
Derrick Hammer 2024-01-24 02:32:49 -05:00
parent 9b464e0932
commit d734e1a89b
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
3 changed files with 22 additions and 0 deletions

View File

@ -29,4 +29,6 @@ type Node interface {
GetMetadataByCID(cid *encoding.CID) (metadata.Metadata, error)
WaitOnConnectedPeers()
ConnectionTracker() *sync.WaitGroup
SetProviderStore(store ProviderStore)
ProviderStore() ProviderStore
}

View File

@ -0,0 +1,11 @@
package interfaces
import (
"git.lumeweb.com/LumeWeb/libs5-go/encoding"
"git.lumeweb.com/LumeWeb/libs5-go/types"
)
type ProviderStore interface {
CanProvide(hash *encoding.Multihash, kind []types.StorageLocationType) bool
Provide(hash *encoding.Multihash, kind []types.StorageLocationType) (StorageLocation, error)
}

View File

@ -34,6 +34,7 @@ type NodeImpl struct {
services interfaces.Services
httpClient *resty.Client
connections sync.WaitGroup
providerStore interfaces.ProviderStore
}
func (n *NodeImpl) NetworkId() string {
@ -333,3 +334,11 @@ func (n *NodeImpl) WaitOnConnectedPeers() {
func (n *NodeImpl) ConnectionTracker() *sync.WaitGroup {
return &n.connections
}
func (n *NodeImpl) SetProviderStore(store interfaces.ProviderStore) {
n.providerStore = store
}
func (n *NodeImpl) ProviderStore() interfaces.ProviderStore {
return n.providerStore
}