plumtree / org.apache.tuweni.plumtree / State

State

class State (source)

Local state to our peer, representing the make-up of the tree of peers.

Constructors

<init>

State(peerRepository: PeerRepository, messageHashingFunction: MessageHashing, messageSender: MessageSender, messageListener: MessageListener, messageValidator: MessageValidator, peerPruningFunction: PeerPruning)

Constructor using default time constants.

State(peerRepository: PeerRepository, messageHashingFunction: MessageHashing, messageSender: MessageSender, messageListener: MessageListener, messageValidator: MessageValidator, peerPruningFunction: PeerPruning, graftDelay: Long, lazyQueueInterval: Long)

Default constructor.

Functions

addPeer

fun addPeer(peer: Peer): Unit

Adds a new peer to this state.

receiveGossipMessage

fun receiveGossipMessage(peer: Peer, attributes: String, message: Bytes, messageHash: Bytes): Unit

Records a message was received in full from a peer.

receiveGraftMessage

fun receiveGraftMessage(peer: Peer, messageHash: Bytes): Unit

Requests a peer be grafted to the eager peers list.

receiveIHaveMessage

fun receiveIHaveMessage(peer: Peer, messageHash: Bytes): Unit

Records a message was partially received from a peer.

receivePruneMessage

fun receivePruneMessage(peer: Peer): Unit

Requests a peer be pruned away from the eager peers into the lazy peers.

removePeer

fun removePeer(peer: Peer): Unit

Removes a peer from the collection of peers we are connected to.

sendGossipMessage

fun sendGossipMessage(attributes: String, message: Bytes): Bytes

Sends a gossip message to all peers, according to their status.

stop

fun stop(): Unit

Stops the gossip network state, cancelling all in progress tasks.