mirror of
https://github.com/PeernetOfficial/core.git
synced 2026-07-17 02:47:51 +01:00
25 lines
638 B
Go
25 lines
638 B
Go
package search
|
|
|
|
import (
|
|
"github.com/PeernetOfficial/core/protocol"
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// SearchNodeIDBasedOnHash Provides a list of NodeIDs
|
|
// based on the hash provided
|
|
// This is used to find out which nodes are hosting
|
|
// which files based on the hash provided
|
|
func (index *SearchIndexStore) SearchNodeIDBasedOnHash(hash []byte) (NodeIDs [][]byte, err error) {
|
|
var resultMap map[uuid.UUID]*SearchIndexRecord
|
|
err = index.LookupHash(SearchSelector{Hash: hash}, resultMap)
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
for i := range resultMap {
|
|
NodeIDs = append(NodeIDs, protocol.PublicKey2NodeID(resultMap[i].PublicKey))
|
|
}
|
|
|
|
return
|
|
}
|