Skip to content
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

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

envestcc
Copy link
Member

@envestcc envestcc commented Feb 27, 2023

summary:

  • Broadcast support unsubscribed topic
  • add ConnectedPeersByBroadcastTopic

p2p.go Outdated Show resolved Hide resolved
p2p.go Outdated Show resolved Hide resolved
p2p.go Show resolved Hide resolved
p2p.go Outdated Show resolved Hide resolved
p2p.go Outdated Show resolved Hide resolved
p2p.go Outdated Show resolved Hide resolved
p2p.go Outdated Show resolved Hide resolved
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
Copy link
Member

@dustinxie dustinxie Mar 8, 2023

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)
}
Copy link
Member

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) {
Copy link
Member

@dustinxie dustinxie Mar 8, 2023

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)

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
Comment on lines 266 to 268
pubsub *pubsub.PubSub
pubs sync.Map
mutex sync.Mutex

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

@envestcc envestcc changed the title support get connected peers by topic support broadcast unsubscribe topic Aug 3, 2023
@envestcc envestcc changed the title support broadcast unsubscribe topic support broadcast to unsubscribe topic Aug 3, 2023
@envestcc envestcc marked this pull request as ready for review August 3, 2023 03:05
@@ -16,7 +16,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.14
go-version: 1.18.5
Copy link
Member

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)
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants