From 959cb39fc92c6e0654d710c846733ba0e796ac54 Mon Sep 17 00:00:00 2001 From: Hussam Date: Tue, 14 May 2024 10:16:07 -0500 Subject: [PATCH] Fix topicfromstring --- p2p/node/api.go | 3 --- p2p/node/pubsubManager/gossipsub.go | 3 --- p2p/node/pubsubManager/utils.go | 4 ++-- quai/p2p_backend.go | 2 ++ 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/p2p/node/api.go b/p2p/node/api.go index cc6e253740..f36d73f041 100644 --- a/p2p/node/api.go +++ b/p2p/node/api.go @@ -195,9 +195,6 @@ func (p *P2PNode) requestAndWait(peerID peer.ID, topic *pubsubManager.Topic, req // Request a data from the network for the specified slice func (p *P2PNode) Request(location common.Location, requestData interface{}, responseDataType interface{}) chan interface{} { - if location.Context() == common.REGION_CTX { - log.Global.Print("fake") - } topic, err := pubsubManager.NewTopic(p.pubsub.GetGenesis(), location, responseDataType) if err != nil { log.Global.WithFields(log.Fields{ diff --git a/p2p/node/pubsubManager/gossipsub.go b/p2p/node/pubsubManager/gossipsub.go index e0cf748dd7..62608c210d 100644 --- a/p2p/node/pubsubManager/gossipsub.go +++ b/p2p/node/pubsubManager/gossipsub.go @@ -196,9 +196,6 @@ func (g *PubsubManager) Unsubscribe(location common.Location, datatype interface // broadcasts data to subscribing peers func (g *PubsubManager) Broadcast(location common.Location, datatype interface{}) error { - if location.Context() == common.REGION_CTX { - log.Global.Print("fake") - } topicName, err := NewTopic(g.genesis, location, datatype) if err != nil { return err diff --git a/p2p/node/pubsubManager/utils.go b/p2p/node/pubsubManager/utils.go index 1e375984c4..d85a853358 100644 --- a/p2p/node/pubsubManager/utils.go +++ b/p2p/node/pubsubManager/utils.go @@ -86,7 +86,7 @@ func TopicFromString(genesis common.Hash, topic string) (*Topic, error) { var location common.Location locationStr := strings.Split(topicParts[1], ",") if len(locationStr) > 0 { - if len(locationStr) >= 1 { + if len(locationStr) >= 1 && locationStr[0] != "" { // Region specified region, err := strconv.Atoi(locationStr[0]) if err != nil { @@ -94,7 +94,7 @@ func TopicFromString(genesis common.Hash, topic string) (*Topic, error) { } location.SetRegion(region) } - if len(locationStr) == 2 { + if len(locationStr) == 2 && locationStr[1] != "" { // Zone specified zone, err := strconv.Atoi(locationStr[1]) if err != nil { diff --git a/quai/p2p_backend.go b/quai/p2p_backend.go index 81b822098d..aa78f81478 100644 --- a/quai/p2p_backend.go +++ b/quai/p2p_backend.go @@ -98,8 +98,10 @@ func (qbe *QuaiBackend) OnNewBroadcast(sourcePeer p2p.PeerID, topic string, data if backend.ProcessingState() { backend.SendRemoteTxs(data) } + case types.Header: default: // TODO: Remove panic and gracefully return + log.Global.Error("Received unknown broadcast") panic("not supposed to happen in dev environment") return false }