Struct UtreexoNode

Source
pub struct UtreexoNode<Chain: ChainBackend, Context = RunningNode> { /* private fields */ }
Available on non-WebAssembly only.
Expand description

The main node that operates while florestad is up.

UtreexoNode aims to be modular where Chain can be any implementation of a ChainBackend.

Context refers to which state the UtreexoNode is on, being RunningNode, SyncNode, and ChainSelector. Defaults to RunningNode which automatically transitions between contexts.

Implementations§

Source§

impl<Chain> UtreexoNode<Chain, ChainSelector>
where Chain: ChainBackend + 'static, WireError: From<Chain::Error>, Chain::Error: From<UtreexoLeafError>,

Source

pub async fn run(&mut self) -> Result<(), WireError>

Source§

impl<T, Chain> UtreexoNode<Chain, T>
where T: 'static + Default + NodeContext, Chain: ChainBackend + 'static, WireError: From<Chain::Error>,

Source

pub fn new( config: UtreexoNodeConfig, chain: Chain, mempool: Arc<Mutex<Mempool>>, block_filters: Option<Arc<NetworkFilters<FlatFiltersStore>>>, kill_signal: Arc<RwLock<bool>>, address_man: AddressMan, ) -> Result<Self, WireError>

Source

pub fn get_handle(&self) -> NodeInterface

Returns a handle to the node interface that we can use to request data from our node. This struct is thread safe, so we can use it from multiple threads and have multiple handles. It also doesn’t require a mutable reference to the node, or any synchronization mechanism.

Source

pub async fn handle_addnode_add_peer( &mut self, addr: IpAddr, port: u16, v2_transport: bool, ) -> Result<(), WireError>

Handles addnode-RPC Add requests, adding a new peer to the added_peers list. This means the peer is marked as a “manually added peer”. We then try to connect to it, or retry later.

Source

pub fn handle_addnode_remove_peer( &mut self, addr: IpAddr, port: u16, ) -> Result<(), WireError>

Handles remove node requests, removing a peer from the node.

Removes a node from the [added_peers] list but does not disconnect the node if it was already connected. It only ensures that the node is no longer treated as a manually added node (i.e., it won’t be reconnected if disconnected).

If someone wants to remove a peer, it should be done using the disconnectnode.

Source

pub async fn handle_addnode_onetry_peer( &mut self, addr: IpAddr, port: u16, v2_transport: bool, ) -> Result<(), WireError>

Handles addnode onetry requests, connecting to the node and this will try to connect to the given address and port. If it’s successful, it will add the node to the peers list, but not to the added_peers list (e.g., it won’t be reconnected if disconnected).

Source§

impl<Chain> UtreexoNode<Chain, RunningNode>
where Chain: ThreadSafeChain + Clone, WireError: From<Chain::Error>, Chain::Error: From<UtreexoLeafError>,

Source

pub async fn catch_up(self) -> Result<Self, WireError>

Every time we restart the node, we’ll be a few blocks behind the tip. This function will start a sync node that will request, download and validate all blocks from the last validation index to the tip. This function will block until the sync node is finished.

On the first startup, if we use either assumeutreexo or pow fraud proofs, this function will only download the blocks that are after the one that got assumed. So, for PoW fraud proofs, this means the last 100 blocks, and for assumeutreexo, this means however many blocks from the hard-coded value in the config file.

Source

pub fn backfill(&self, done_flag: Sender<()>) -> Result<bool, WireError>

If either PoW fraud proofs or assumeutreexo are enabled, we will “skip” IBD for all historical blocks. This allow us to start the node faster, making it usable in a few minutes. If you still want to validate all blocks, you can enable the backfill option.

This function will spawn a background task that will download and validate all blocks that got assumed. After completion, the task will shutdown and the node will continue running normally. If we ever assume an invalid chain, the node will halt and catch fire.

Source

pub async fn run(self, stop_signal: Sender<()>)

Source§

impl<Chain> UtreexoNode<Chain, SyncNode>
where Chain: ThreadSafeChain, WireError: From<Chain::Error>, Chain::Error: From<UtreexoLeafError>,

Node methods for a UtreexoNode where its Context is a SyncNode. See node for more information.

Source

pub async fn run(self, done_cb: impl FnOnce(&Chain)) -> Self

Starts the sync node by updating the last block requested and starting the main loop. This loop to the following tasks, in order: - Receives messages from our peers through the node_tx channel. - Handles the message received. - Checks if the kill signal is set, if so, breaks the loop. - Checks if the chain is in IBD and disables it if it’s not (e.g. if the chain is synced). - Checks if our tip is obsolete and requests a new one, creating a new connection. - Handles timeouts for inflight requests. - If were low on inflights, requests new blocks to validate.

Trait Implementations§

Source§

impl<Chain: ChainBackend, T> Deref for UtreexoNode<Chain, T>

Source§

type Target = NodeCommon<Chain>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<T, Chain: ChainBackend> DerefMut for UtreexoNode<Chain, T>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<Chain, Context> Freeze for UtreexoNode<Chain, Context>
where Context: Freeze, Chain: Freeze,

§

impl<Chain, Context = RunningNode> !RefUnwindSafe for UtreexoNode<Chain, Context>

§

impl<Chain, Context> Send for UtreexoNode<Chain, Context>
where Context: Send, Chain: Send,

§

impl<Chain, Context> Sync for UtreexoNode<Chain, Context>
where Context: Sync, Chain: Sync,

§

impl<Chain, Context> Unpin for UtreexoNode<Chain, Context>
where Context: Unpin, Chain: Unpin,

§

impl<Chain, Context = RunningNode> !UnwindSafe for UtreexoNode<Chain, Context>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more