added base changes for the merge cirectory api

This commit is contained in:
2023-03-15 00:30:44 +00:00
parent b34b2e2b7c
commit 712f7cee56
4 changed files with 139 additions and 88 deletions

View 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
}