diff --git a/p2p/node/peerManager/peerManager.go b/p2p/node/peerManager/peerManager.go index be7b443a1d..b5f6019093 100644 --- a/p2p/node/peerManager/peerManager.go +++ b/p2p/node/peerManager/peerManager.go @@ -4,6 +4,7 @@ import ( "context" "maps" "net" + "reflect" "runtime/debug" "strings" "sync" @@ -343,19 +344,25 @@ func (pm *BasicPeerManager) GetPeers(location common.Location, data interface{}, func (pm *BasicPeerManager) queryDHT(location common.Location, data interface{}, peerList map[p2p.PeerID]struct{}, peerCount int) map[p2p.PeerID]struct{} { // create a Cid from the slice location - topicName, _ := pubsubManager.TopicName(pm.genesis, location, data) + topicName, err := pubsubManager.TopicName(pm.genesis, location, data) + if err != nil { + log.Global.WithFields(log.Fields{ + "location": location, + "dataType": reflect.TypeOf(data), + }).Error("Unable to find topic for requested data") + } topicCid := pubsubManager.TopicToCid(topicName) // Internal list of peers from the dht dhtPeers := make(map[p2p.PeerID]struct{}) - log.Global.Infof("Querying DHT for slice Cid %s", topicCid) + log.Global.WithField("topic", topicName).Infof("Querying DHT for topic") // query the DHT for peers in the slice for peer := range pm.dht.FindProvidersAsync(pm.ctx, topicCid, peerCount) { if peer.ID != pm.selfID { dhtPeers[peer.ID] = struct{}{} } } - log.Global.Warn("Found the following peers from the DHT: ", dhtPeers) + log.Global.Info("Found the following peers from the DHT: ", dhtPeers) maps.Copy(peerList, dhtPeers) return peerList } diff --git a/p2p/node/pubsubManager/utils.go b/p2p/node/pubsubManager/utils.go index d934adada0..f7abffe7bc 100644 --- a/p2p/node/pubsubManager/utils.go +++ b/p2p/node/pubsubManager/utils.go @@ -2,6 +2,7 @@ package pubsubManager import ( "errors" + "math/big" "strings" "github.com/dominant-strategies/go-quai/common" @@ -17,7 +18,6 @@ const ( C_workObjectType = "blocks" C_transactionType = "transactions" C_headerType = "headers" - C_hashType = "hash" C_workObjectHeaderType = "woHeaders" ) @@ -25,10 +25,10 @@ const ( func TopicName(genesis common.Hash, location common.Location, data interface{}) (string, error) { baseTopic := strings.Join([]string{genesis.String(), location.Name()}, "/") switch data.(type) { - case *types.WorkObject: + case *types.WorkObject, *big.Int, common.Hash: return strings.Join([]string{baseTopic, C_workObjectType}, "/"), nil - case common.Hash: - return strings.Join([]string{baseTopic, C_hashType}, "/"), nil + case *types.Transaction: + return strings.Join([]string{baseTopic, C_transactionType}, "/"), nil case *types.Transactions: return strings.Join([]string{baseTopic, C_transactionType}, "/"), nil case *types.WorkObjectHeader: