Skip to Content
Hands-On Blockchain for Python Developers
book

Hands-On Blockchain for Python Developers

by Arjuna Sky Kok
February 2019
Intermediate to advanced
450 pages
9h 59m
English
Packt Publishing
Content preview from Hands-On Blockchain for Python Developers

Pubsub

The IPFS has an experimental feature, which is Publish-Subscribe, or pubsub. Basically, a node in the IPFS can subscribe to a topic. Let's say this topic is a Bitcoin topic. A node in the IPFS can publish a To the moon! message to a bitcoin topic. Then, any node that subscribes to the 'bitcoin' topic could get the message.

Because pubsub is an experimental feature, you need to run IPFS daemon with a particular flag. Run IPFS daemon with the --enable-pubsub-experiment flag using the following command:

$ ipfs daemon --enable-pubsub-experiment

Both the subscriber and the publisher need to run the daemon with this particular flag.

Let's create a script to subscribe to a certain topic and name the script subscribe_topic.py:

import ipfsapi ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Blockchain in Action

Blockchain in Action

Bina Ramamurthy
Learn Python by Building a Blockchain and Cryptocurrency

Learn Python by Building a Blockchain and Cryptocurrency

Academind by Maximilian Schwarzmüller GmbH

Publisher Resources

ISBN: 9781788627856Supplemental Content