Crate subcoin_network

Source
Expand description

§Bitcoin Network

This crate facilitates communication with other nodes in the Bitcoin P2P network. It handles connections, message transmission, and the peer-to-peer protocol.

§Initial Block Download

This crate offers two strategies for the initial block download:

  • Blocks-First: Downloads the full block data sequentially starting from the last known block until it’s fully synced with the network, in batches. This is primarily for the testing purpose.

  • Headers-First: First downloads the block headers and then proceeds to the full block data based on the checkpoints.

However, due to the nature of Subcoin, building a Bitcoin SPV node solely by syncing Bitcoin headers from the network is not possible, in that Subcoin requires full block data to derive the corresponding substrate header properly, including generating the extrinsics_root and state_root.

§Subcoin Bootstrap Node

Subcoin node runs the Bitcoin networking and Substrate networking in parallel. Initial block download from Bitcoin p2p network is time-consuming because every historical block must be downloaded and executed. The advantage of Subcoin node is that only the Subcoin bootstrap node needs to perform full block sync. Once Subcoin bootstrap nodes are operational in the network, newly joined Subcoin nodes can quickly sync to Bitcoin chain’s tip by leveraging the advanced state sync provided by the Substrate networking stack.

Structs§

Config
Network configuration.
MemoryConfig
Memory management configuration for network operations.
NetworkHandle
A handle for interacting with the network processor.
NetworkStatus
Represents the status of network.
NoNetwork
Subcoin network disabled.
OfflineSync
Subcoin network is disabled, but chain is syncing from other source, e.g., importing blocks from the Bitcoind database.
PeerSync
Contains all the data about a Peer that we are trying to sync with.

Enums§

BlockSyncOption
Controls the block sync from Bitcoin P2P network.
Error
Network error type.
PeerSyncState
The state of syncing between a Peer and ourselves.
SendTransactionResult
Represents the result of submitting a transaction to the network.
SyncStatus
Represents the sync status of node.
SyncStrategy
Represents the strategy for block syncing.

Traits§

NetworkApi
Subcoin network service interface.

Functions§

build_network
Creates Subcoin network.

Type Aliases§

Latency
Peer latency in milliseconds.
PeerId
Identifies a peer.