-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support broadcast to unsubscribe topic #36
base: master
Are you sure you want to change the base?
Conversation
p2p.go
Outdated
@@ -501,7 +502,7 @@ func (h *Host) AddBroadcastPubSub(ctx context.Context, topic string, callback Ha | |||
if err != nil { | |||
return err | |||
} | |||
h.pubs[topic] = top | |||
h.pubs.Store(topic, top) | |||
h.blacklists[topic] = blacklist | |||
h.subs[topic] = sub |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make L488 - 491 + 496 a func getOrAddPub(topic string)
} | ||
} else { | ||
pub = pubVal.(*pubsub.Topic) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub, err := h.getOrAddPubsub(topic)
p2p.go
Outdated
@@ -731,6 +746,22 @@ func (h *Host) allowSource(src core.PeerID) (bool, error) { | |||
return limiter.Allow(), nil | |||
} | |||
|
|||
func (h *Host) addPub(topic string) (*pubsub.Topic, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getOrAddPub
p2p.go
Outdated
if h.pubsub == nil { | ||
return peers | ||
} | ||
topicPeerIDs := h.pubsub.ListPeers(topic) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
convert to map
p2p.go
Outdated
pubsub *pubsub.PubSub | ||
pubs sync.Map | ||
mutex sync.Mutex |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create a new struct to hold these three parameters
@@ -16,7 +16,7 @@ jobs: | |||
- name: Set up Go | |||
uses: actions/setup-go@v2 | |||
with: | |||
go-version: 1.14 | |||
go-version: 1.18.5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
upgrading golang in a separate pr
return err | ||
} | ||
// publishing unsubscribed topic will fail when no connected peers, it should return error | ||
_, subscribed := h.pubsubManager.getSub(topic) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how is the subscription of topics from connected peers detected?
summary:
Broadcast
support unsubscribed topicConnectedPeersByBroadcastTopic