pub enum Node<N: Network> {
Validator(Arc<Validator<N, ConsensusDB<N>>>),
Prover(Arc<Prover<N, ConsensusMemory<N>>>),
Client(Arc<Client<N, ConsensusDB<N>>>),
BootstrapClient(BootstrapClient<N>),
}Variants§
Validator(Arc<Validator<N, ConsensusDB<N>>>)
A validator is a full node, capable of validating blocks.
Prover(Arc<Prover<N, ConsensusMemory<N>>>)
A prover is a light node, capable of producing proofs for consensus.
Client(Arc<Client<N, ConsensusDB<N>>>)
A client node is a full node, capable of querying with the network.
BootstrapClient(BootstrapClient<N>)
A bootstrap client node is a light node dedicated to serving lists of peers.
Implementations§
Source§impl<N: Network> Node<N>
impl<N: Network> Node<N>
Sourcepub async fn new_validator(
node_ip: SocketAddr,
bft_ip: Option<SocketAddr>,
rest_ip: Option<SocketAddr>,
rest_rps: u32,
account: Account<N>,
trusted_peers: &[SocketAddr],
trusted_validators: &[SocketAddr],
genesis: Block<N>,
cdn: Option<Uri>,
storage_mode: StorageMode,
trusted_peers_only: bool,
dev_txs: bool,
dev: Option<u16>,
shutdown: Arc<AtomicBool>,
) -> Result<Self>
pub async fn new_validator( node_ip: SocketAddr, bft_ip: Option<SocketAddr>, rest_ip: Option<SocketAddr>, rest_rps: u32, account: Account<N>, trusted_peers: &[SocketAddr], trusted_validators: &[SocketAddr], genesis: Block<N>, cdn: Option<Uri>, storage_mode: StorageMode, trusted_peers_only: bool, dev_txs: bool, dev: Option<u16>, shutdown: Arc<AtomicBool>, ) -> Result<Self>
Initializes a new validator node.
Sourcepub async fn new_prover(
node_ip: SocketAddr,
account: Account<N>,
trusted_peers: &[SocketAddr],
genesis: Block<N>,
storage_mode: StorageMode,
trusted_peers_only: bool,
dev: Option<u16>,
shutdown: Arc<AtomicBool>,
) -> Result<Self>
pub async fn new_prover( node_ip: SocketAddr, account: Account<N>, trusted_peers: &[SocketAddr], genesis: Block<N>, storage_mode: StorageMode, trusted_peers_only: bool, dev: Option<u16>, shutdown: Arc<AtomicBool>, ) -> Result<Self>
Initializes a new prover node.
Sourcepub async fn new_client(
node_ip: SocketAddr,
rest_ip: Option<SocketAddr>,
rest_rps: u32,
account: Account<N>,
trusted_peers: &[SocketAddr],
genesis: Block<N>,
cdn: Option<Uri>,
storage_mode: StorageMode,
trusted_peers_only: bool,
dev: Option<u16>,
shutdown: Arc<AtomicBool>,
) -> Result<Self>
pub async fn new_client( node_ip: SocketAddr, rest_ip: Option<SocketAddr>, rest_rps: u32, account: Account<N>, trusted_peers: &[SocketAddr], genesis: Block<N>, cdn: Option<Uri>, storage_mode: StorageMode, trusted_peers_only: bool, dev: Option<u16>, shutdown: Arc<AtomicBool>, ) -> Result<Self>
Initializes a new client node.
Sourcepub async fn new_bootstrap_client(
listener_addr: SocketAddr,
account: Account<N>,
genesis_header: Header<N>,
dev: Option<u16>,
) -> Result<Self>
pub async fn new_bootstrap_client( listener_addr: SocketAddr, account: Account<N>, genesis_header: Header<N>, dev: Option<u16>, ) -> Result<Self>
Initializes a new bootstrap client node.
Sourcepub fn private_key(&self) -> &PrivateKey<N>
pub fn private_key(&self) -> &PrivateKey<N>
Returns the account private key of the node.
Sourcepub fn peer_pool(&self) -> &RwLock<HashMap<SocketAddr, Peer<N>>>
pub fn peer_pool(&self) -> &RwLock<HashMap<SocketAddr, Peer<N>>>
Returns a reference to the underlying peer pool.
Sourcepub fn ledger(&self) -> Option<&Ledger<N, ConsensusDB<N>>>
pub fn ledger(&self) -> Option<&Ledger<N, ConsensusDB<N>>>
Get the underlying ledger (if any).
Sourcepub fn is_block_synced(&self) -> bool
pub fn is_block_synced(&self) -> bool
Returns true if the node is synced up to the latest block (within the given tolerance).
Sourcepub fn num_blocks_behind(&self) -> Option<u32>
pub fn num_blocks_behind(&self) -> Option<u32>
Returns the number of blocks this node is behind the greatest peer height,
or None if not connected to peers yet.
Sourcepub fn get_sync_speed(&self) -> f64
pub fn get_sync_speed(&self) -> f64
Calculates the current sync speed in blocks per second. Returns None if sync speed cannot be calculated (e.g., not syncing or insufficient data).
Trait Implementations§
Auto Trait Implementations§
impl<N> Freeze for Node<N>
impl<N> !RefUnwindSafe for Node<N>
impl<N> Send for Node<N>
impl<N> Sync for Node<N>
impl<N> Unpin for Node<N>
impl<N> !UnwindSafe for Node<N>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more