Search in sources :

Example 1 with PubsubSubscription

use of io.libp2p.core.pubsub.PubsubSubscription in project teku by ConsenSys.

the class LibP2PGossipNetwork method subscribe.

@Override
public TopicChannel subscribe(final String topic, final TopicHandler topicHandler) {
    LOG.trace("Subscribe to topic: {}", topic);
    topicHandlers.add(topic, topicHandler);
    final Topic libP2PTopic = new Topic(topic);
    final GossipHandler gossipHandler = new GossipHandler(metricsSystem, libP2PTopic, publisher, topicHandler);
    PubsubSubscription subscription = gossip.subscribe(gossipHandler, libP2PTopic);
    return new LibP2PTopicChannel(gossipHandler, subscription);
}
Also used : PubsubSubscription(io.libp2p.core.pubsub.PubsubSubscription) Topic(io.libp2p.core.pubsub.Topic)

Aggregations

PubsubSubscription (io.libp2p.core.pubsub.PubsubSubscription)1 Topic (io.libp2p.core.pubsub.Topic)1