Skip to content

Using a combination of ZeroMQ and RPC the gadget communicates with another instance of itself and allows two nodes mempools to be synced with near minimal bandwidth in 2 round trips.

Notifications You must be signed in to change notification settings

hlb8122/mempool-sync-gadget

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mempool Synchronization Gadget

A gadget communicates with its accompanying Bitcoin node via ZeroMQ and RPC, and with other gadgets via raw TCP in order to syncronize mempools with near minimal bandwidth in 2 round trips. If the the mempools become sync'd part way through the protocol it terminates, giving a lower than 2 round trip average.

Build Status

Prerequisites

sudo apt install clang libzmq3-dev libssl-dev

ZeroMQ

Start Bitcoin's ZeroMQ publishers using

bitcoind -zmqpubhashblock=tcp://127.0.0.1:28332 -zmqpubrawtx=tcp://127.0.0.1:28332

or by adding

zmqpubhashblock=tcp://127.0.0.1:28332
zmqpubrawtx=tcp://127.0.0.1:28332

to your bitcoin.conf.

RPC

Allow Bitcoin to accept RPC connections. See here

Running

Once two nodes are running, both with RPC and ZMQ enabled:

Machine A

cargo build --release
cd target/release
mempool-sync-gadget --rpcusername xxxxxx --rpcpassword yyyyyy

Machine B

cargo build --release
cd target/release
mempool-sync-gadget --peerip X.X.X.X --peerport Y --rpcusername xxxxxx --rpcpassword yyyyyy

where X.X.X.X:Y is the address of machine A.

For more options mempool-sync-gadget --help.

Notes

  • All communication is asynchronous, however blocking does occur due to the mutex locking around the gadgets mempool.
  • The minisketch-rs library seems to try build using a Linux only header file.
  • If a gadget receives a transaction from another gadget, sends it to the mempool just after the same transaction arrives at the node Rpc(Object({"code": Number(-25), "message": String("Missing inputs")})) error will be thrown and handled gracefully.

About

Using a combination of ZeroMQ and RPC the gadget communicates with another instance of itself and allows two nodes mempools to be synced with near minimal bandwidth in 2 round trips.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages