The implementation of BIP 156 (Dandelion transaction relay) is done in three steps:
Add the protocol messages
dandeliontx
, which contains a transaction serialized with all witness datadandelionacc
, which is always empty and only used to signal dandelion support to other peers
Shuffle dandelion stems
We shuffle a list of all peers that sent us the message that they accept dandelion txs (dandelionacc
). This list can be used on demand by nodes that want to forward a dandelion transaction. (Actual receiving of dandelion txs is done in the next step).
Also, we add a command line option -dandelion
, which can be used to opt out of all dandelion features.
Keep a cache of recent dandelion transactions
Dandelion transactions are never added to the global tx pool and only forwarded to one peer (the next hop in the stem). To guard against the next peer going offline, we keep a cache of recent dandelion transactions that are not yet fluffed (added to the mempool) or mined. Entries in this cache expire after some random timeout and transition to fluff phase.