mirror of
https://github.com/PeernetOfficial/core.git
synced 2026-07-21 04:17:50 +01:00
added base changes for the merge cirectory api
This commit is contained in:
24
search/Search NodeIDs Based on Hash.go
Normal file
24
search/Search NodeIDs Based on Hash.go
Normal file
@@ -0,0 +1,24 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user