CommonCnxnMgr

abstract class CommonCnxnMgr(netType: ChainSelector) : CnxnMgr

Inheritors

Constructors

Link copied to clipboard
constructor(netType: ChainSelector)

Properties

Link copied to clipboard

Tell peers to only be interested in things that match this bloom

Link copied to clipboard
val bannedLock: iMutex

Don't reconnect to these nodes

Link copied to clipboard
Link copied to clipboard

a block has arrived. This could be a BCHBlock or a MerkleBlock

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

If the connection state changes, this function will be called

Link copied to clipboard
val cnxnLock: iGate

All current connections

Link copied to clipboard
Link copied to clipboard

True if the connection manager should stop operating & clean up any threads

Link copied to clipboard
Link copied to clipboard
open override val electrumCnxns: List<ElectrumClient>

Get the current list of electrum protocol connections It is better to use the connection getter functions, rather than accessing this list. This is meant for display, health and statistics, rather than access

Link copied to clipboard

supply electrum server ip and ports if we need them

Link copied to clipboard

a block header has arrived

Link copied to clipboard
var invCallback: (List<Inv>) -> Unit?

a notification of an object's existence has arrived

Link copied to clipboard
abstract val name: String

returns this connection manager's name (typically the blockchain's name). used for logging/debug

Link copied to clipboard
open override val p2pCnxns: List<P2pClient>

Get the current list of peer-to-peer connections It is better to use the connection getter functions, rather than accessing this list. This is meant for display, health and statistics, rather than access

Link copied to clipboard

A partially complete MerkleBlock arrived

Link copied to clipboard

if this is not null, try all communications to this connection first

Link copied to clipboard
var processingThread: iThread?
Link copied to clipboard
open override val rejectHandler: Callbacker<RejectInfo>

Add a callback to handle incoming transactions

Link copied to clipboard
Link copied to clipboard
open override val size: Int

Returns the number of currently connected peers.

Link copied to clipboard

If a message of a certain type comes in, call this callback with the message for processing

Link copied to clipboard
val wakingDelay: iGate

Functions

Link copied to clipboard
abstract fun add(inIpp: IpPort, priority: Int, keepForever: Boolean)

Add a potential node into the list of possible connections. If inIpp resolves to multiple addresses, a random one is chosen

abstract fun add(ip: String, port: Int = -1, priority: Int = 0, keepForever: Boolean = false)

Add a potential node into the list of possible connections

Link copied to clipboard
open override fun addBlockHandler(cb: (List<out iBlockHeader>) -> Unit)

Add a callback to handle incoming blocks -- downcast the parameter to either BCHBlock or MerkleBlock

Link copied to clipboard
open override fun addBlockHeadersHandler(cb: (List<out iBlockHeader>) -> Unit)

Add a callback to handle incoming block headers

Link copied to clipboard
open override fun addInvHandler(cb: (List<Inv>) -> Unit)

Add a callback to handle incoming inventory (right now, only blocks, the CnxnMgr auto-handles tx INVs)

Link copied to clipboard
open override fun addPartialBlockHandler(cb: (List<out iMerkleBlock>) -> Unit)

Add a callback to handle incoming incomplete MerkleBlocks

Link copied to clipboard
open override fun addTxHandler(cb: (List<out iTransaction>) -> Unit)

Add a callback to handle incoming transactions

Link copied to clipboard
open override fun broadcastMsg(msg: CapdMsg)
Link copied to clipboard
open override fun broadcastTransaction(tx: ByteArray)
Link copied to clipboard
open override fun clear()

clear all incoming messages, drop all connections

Link copied to clipboard
open override fun clearBanned(ip: String?)

remove a node (or all nodes if ip==null) from the ban table

Link copied to clipboard
open override fun connectedTo(ip: String, port: Int): Boolean

Returns true if we are connected to this node/port

Link copied to clipboard
open suspend override fun coReport(problemCnxn: P2pClient?)

wake up and analyze my connections, especially the optional passed connection

Link copied to clipboard
abstract fun exclusiveNodes(nodes: Set<String>?)

Exclusively connect to a single node. All other existing connections will be dropped

Link copied to clipboard
open override fun getAnotherElectrum(notThese: Set<ElectrumClient>): ElectrumClient?

Returns a random connection from the connection manager's node set, but not one of these. Returns null if no connections left

Link copied to clipboard
open override fun getAnotherNode(notThese: Set<P2pClient>): P2pClient?

Returns a random connection from the connection manager's node set, but not one of these. Returns null if no connections left

Link copied to clipboard
open override fun getElectrum(): ElectrumClient

Returns a random connection from the connection manager's node set

Link copied to clipboard
open override fun getNode(block: Int): P2pClient

Returns a random connection from the connection manager's node set

Link copied to clipboard
open suspend override fun getp2p(): P2pClient

Returns a random connection from the connection manager's node set

Link copied to clipboard

Loops looking for an alive connection, returns null if no connections are left

Link copied to clipboard
open override fun <T> mapConnections(mapfilter: (P2pClient) -> T?): List<T>

Returns a list of connected peers. This API works simultaneously as map (transformation) and filter functions and calls the passed function on every item in the connection list.

Link copied to clipboard
abstract fun misbehaving(cnxn: P2pClient, reason: BanReason, count: Int = 100)

report a node as having a problem

Link copied to clipboard
open override fun numPeers(): Int

Returns the number of currently connected peers

Link copied to clipboard
abstract fun preferNodes(nodes: Set<String>?)

Prefer a particular node. An existing connections may be dropped to make room

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override fun report(problemCnxn: P2pClient?)

wake up and analyze my connections, especially the optional passed connection

Link copied to clipboard
open override fun restart()

Restart connection manager operation after suspend may have killed threads

Link copied to clipboard

Returns an electrum connection. DO NOT USE AFTER RETURNING

Link copied to clipboard
open override fun sendTransaction(tx: ByteArray)

Send a transaction to one node

Link copied to clipboard
open override fun sendTransactions(txes: List<ByteArray>): Boolean

Broadcast a set of transactions to the network, returns true if transactions were sent (otherwise no nodes are available).

Link copied to clipboard
open override fun setAddressFilter(bloom: ByteArray, onBloomInstalled: () -> Unit?)

tell all nodes, including future connections, that we are only interested in things that match this bloom filter. To enable multiple wallets to use the same Blockchain, do NOT use this API directly. Instead use the blockchain API

Link copied to clipboard
open override fun start()

Start the connection manager processing thread

Link copied to clipboard
open override fun stop()

Stop the connection manager processing thread asynchronously