pybitmessage.network.dandelion module

Dandelion class definition, tracks stages

class Stem(child, stream, timeout)[source]

Bases: tuple

child

Alias for field number 0

stream

Alias for field number 1

timeout

Alias for field number 2

class Dandelion[source]

Dandelion class for tracking stem/fluff stages.

static poissonTimeout(start=None, average=0)

Generate deadline using Poisson distribution

addHash(hashId, source=None, stream=1)

Add inventory vector to dandelion stem

setHashStream(hashId, stream=1)

Update stream for inventory vector (as inv/dinv commands don’t include streams, we only learn this after receiving the object)

removeHash(hashId, reason='no reason specified')

Switch inventory vector from stem to fluff mode

hasHash(hashId)

Is inventory vector in stem mode?

objectChildStem(hashId)

Child (i.e. next) node for an inventory vector during stem mode

maybeAddStem(connection)

If we had too few outbound connections, add the current one to the current stem list. Dandelion as designed by the authors should always have two active stem child connections.

maybeRemoveStem(connection)

Remove current connection from the stem list (called e.g. when a connection is closed).

pickStem(parent=None)

Pick a random active stem, but not the parent one (the one where an object came from)

getNodeStem(node=None)

Return child stem node for a given parent stem node (the mapping is static for about 10 minutes, then it reshuffles)

expire()

Switch expired objects from stem to fluff mode

reRandomiseStems()

Re-shuffle stem mapping (parent <-> child pairs)