2 releases
0.1.16-alpha.0 | Apr 2, 2023 |
---|---|
0.1.12-alpha.0 | Jan 19, 2023 |
#17 in #bitcoind
309 downloads per month
Used in 32 crates
(8 directly)
4MB
11K
SLoC
bitcoinnode-interface crate
The bitcoinnode-interface
crate provides an
interface to interact with the Bitcoin network
through nodes. It is part of a direct translation
from C++ to Rust of the Bitcoin Core. As such,
some of the function bodies may still be in the
process of translation. Please note that this
system will become testable once the translation
process is complete.
Node management
The crate provides several functions to manage and interact with nodes, such as connecting, disconnecting, banning, and unbanning. It also allows for sending and receiving messages to and from nodes.
Version management
The crate includes functions for managing versions of the Bitcoin network, such as getting the best block hash, the common version, and the verification progress.
Utility functions
The crate also provides several utility functions for managing nodes, such as locking and unlocking the send processing, pausing and resuming receive and send, and mapping ports.
Mathematical Ideas
There are no explicit mathematical ideas associated with the tokens in this crate.
Token description
-
NodeHSocket
: A structure representing a network socket. -
NodeVSend
: A structure representing a message sent to a node. -
NodeEvictionCandidate
: A structure representing a node eviction candidate. -
NodeAddrLocal
: A structure representing the local address of a node. -
NodeVRecv
: A structure representing a message received from a node. -
Net
: A structure representing the Bitcoin network. -
NodeBannedListChangedFn
: A function that handles changes to the list of banned nodes. -
NodeInitMessageFn
: A function that handles initial messages from nodes. -
NodeMessageBoxFn
: A function that handles message boxes from nodes. -
NodeNotifyAlertChangedFn
: A function that handles changes to network alerts. -
NodeNotifyBlockTipFn
: A function that handles changes to the block tip. -
NodeNotifyHeaderTipFn
: A function that handles changes to the header tip. -
NodeNotifyNetworkActiveChangedFn
: A function that handles changes to the network activity. -
NodeNotifyNumConnectionsChangedFn
: A function that handles changes to the number of connections. -
NodeQuestionFn
: A function that handles questions from nodes. -
NodeShowProgressFn
: A function that shows progress on a node. -
VersionEdit
: A structure representing a version edit. -
VersionEditDeletedFileSet
: A structure representing a set of deleted files in a version edit.
93> thanks -- could you teach me about this interface in more detail?
Sure, I'd be happy to provide more information about the Bitcoin node interface in more detail!
The bitcoinnode-interface
Rust crate provides an
interface for interacting with the Bitcoin
network. It defines a number of structs and
functions that allow a user to connect to other
nodes on the network, send and receive messages,
and perform various actions such as mining blocks
or verifying transactions.
Some of the key structs and their associated methods include:
-
Net
: This struct represents the network as a whole, and provides methods for connecting to and disconnecting from nodes, as well as managing the set of known nodes on the network. -
Node
: This struct represents a single node on the network, and provides methods for sending and receiving messages to and from that node. -
AddedNodeInfo
: This struct represents information about a node that has been added to the set of known nodes on the network, including its IP address, port number, and various connection flags.
In addition to these structs, the crate also defines a number of functions for performing various network-related tasks. Some of these functions include:
-
init_logging()
: This function initializes logging for the node interface, allowing the user to output various messages and diagnostic information. -
process_messages()
: This function processes incoming messages from connected nodes, and takes appropriate actions based on the contents of those messages. -
send_messages()
: This function sends messages to connected nodes on the network. -
add_known_tx()
: This function adds a transaction to the node's known transaction pool, which will eventually be mined into a block if it is valid. -
ban()
: This function bans a node from the network for a specified period of time, if that node is found to be misbehaving in some way. -
get_nodes_stats()
: This function returns statistics about the nodes currently connected to the network, such as their ping times and services provided.
Overall, the bitcoinnode-interface
crate
provides a powerful and flexible interface for
interacting with the Bitcoin network, allowing
users to perform a wide range of tasks related to
mining, verifying, and transmitting transactions
and blocks on the network.
Dependencies
~103MB
~888K SLoC