feat: add DownloadBytesByCID
This commit is contained in:
parent
f6dc2c1d53
commit
712e216150
|
@ -25,6 +25,7 @@ type Node interface {
|
||||||
AddStorageLocation(hash *encoding.Multihash, nodeId *encoding.NodeId, location StorageLocation, message []byte, config *config.NodeConfig) error
|
AddStorageLocation(hash *encoding.Multihash, nodeId *encoding.NodeId, location StorageLocation, message []byte, config *config.NodeConfig) error
|
||||||
NetworkId() string
|
NetworkId() string
|
||||||
DownloadBytesByHash(hash *encoding.Multihash) ([]byte, error)
|
DownloadBytesByHash(hash *encoding.Multihash) ([]byte, error)
|
||||||
|
DownloadBytesByCID(cid *encoding.CID) (bytes []byte, err error)
|
||||||
GetMetadataByCID(cid *encoding.CID) (metadata.Metadata, error)
|
GetMetadataByCID(cid *encoding.CID) (metadata.Metadata, error)
|
||||||
WaitOnConnectedPeers()
|
WaitOnConnectedPeers()
|
||||||
ConnectionTracker() *sync.WaitGroup
|
ConnectionTracker() *sync.WaitGroup
|
||||||
|
|
|
@ -269,6 +269,15 @@ func (n *NodeImpl) DownloadBytesByHash(hash *encoding.Multihash) ([]byte, error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (n *NodeImpl) DownloadBytesByCID(cid *encoding.CID) (bytes []byte, err error) {
|
||||||
|
bytes, err = n.DownloadBytesByHash(&cid.Hash)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return bytes, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (n *NodeImpl) GetMetadataByCID(cid *encoding.CID) (md metadata.Metadata, err error) {
|
func (n *NodeImpl) GetMetadataByCID(cid *encoding.CID) (md metadata.Metadata, err error) {
|
||||||
hashStr, err := cid.Hash.ToString()
|
hashStr, err := cid.Hash.ToString()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue