Skip to content

Commit

Permalink
Fix topicfromstring
Browse files Browse the repository at this point in the history
  • Loading branch information
Djadih committed May 14, 2024
1 parent 97a2ac3 commit 959cb39
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 8 deletions.
3 changes: 0 additions & 3 deletions p2p/node/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
3 changes: 0 additions & 3 deletions p2p/node/pubsubManager/gossipsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions p2p/node/pubsubManager/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ 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 {
return nil, err
}
location.SetRegion(region)
}
if len(locationStr) == 2 {
if len(locationStr) == 2 && locationStr[1] != "" {
// Zone specified
zone, err := strconv.Atoi(locationStr[1])
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions quai/p2p_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 959cb39

Please sign in to comment.