pub struct Foreign<B, P> where
    B: BlockChain,
    P: PoolAdapter
{ pub chain: Weak<Chain>, pub tx_pool: Weak<RwLock<TransactionPool<B, P>>>, pub sync_state: Weak<SyncState>, }
Expand description

Main interface into all node API functions. Node APIs are split into two seperate blocks of functionality called the ‘Owner’ and ‘Foreign’ APIs

Methods in this API are intended to be ‘single use’.

Fields

chain: Weak<Chain>tx_pool: Weak<RwLock<TransactionPool<B, P>>>sync_state: Weak<SyncState>

Implementations

Create a new API instance with the chain, transaction pool, peers and sync_state. All subsequent API calls will operate on this instance of node API.

Arguments
  • chain - A non-owning reference of the chain.
  • tx_pool - A non-owning reference of the transaction pool.
  • peers - A non-owning reference of the peers.
  • sync_state - A non-owning reference of the sync_state.
Returns
  • An instance of the Node holding references to the current chain, transaction pool, peers and sync_state.

Gets block header given either a height, a hash or an unspent output commitment. Only one parameters is needed. If multiple parameters are provided only the first one in the list is used.

Arguments
  • height - block height.
  • hash - block hash.
  • commit - output commitment.
Returns

Gets block details given either a height, a hash or an unspent output commitment. Only one parameters is needed. If multiple parameters are provided only the first one in the list is used.

Arguments
  • height - block height.
  • hash - block hash.
  • commit - output commitment.
Returns

Returns the node version and block header version (used by grin-wallet).

Returns
  • Result Containing:
  • A Version
  • or Error if an error is encountered.

Returns details about the state of the current fork tip.

Returns
  • Result Containing:
  • A Tip
  • or Error if an error is encountered.

Returns a LocatedTxKernel based on the kernel excess. The min_height and max_height parameters are both optional. If not supplied, min_height will be set to 0 and max_height will be set to the head of the chain. The method will start at the block height max_height and traverse the kernel MMR backwards, until either the kernel is found or min_height is reached.

Arguments
  • excess - kernel excess to look for.
  • min_height - minimum height to stop the lookup.
  • max_height - maximum height to start the lookup.
Returns

Retrieves details about specifics outputs. Supports retrieval of multiple outputs in a single request. Support retrieval by both commitment string and block height.

Arguments
  • commits - a vector of unspent output commitments.
  • start_height - start height to start the lookup.
  • end_height - end height to stop the lookup.
  • include_proof - whether or not to include the range proof in the response.
  • include_merkle_proof - whether or not to include the merkle proof in the response.
Returns

UTXO traversal. Retrieves last utxos since a start_index until a max.

Arguments
  • start_index - start index in the MMR.
  • end_index - optional index so stop in the MMR.
  • max - max index in the MMR.
  • include_proof - whether or not to include the range proof in the response.
Returns

Retrieves the PMMR indices based on the provided block height(s).

Arguments
  • start_block_height - start index in the MMR.
  • end_block_height - optional index so stop in the MMR.
Returns

Returns the number of transaction in the transaction pool.

Returns
  • Result Containing:
  • usize
  • or Error if an error is encountered.

Returns the number of transaction in the stem transaction pool.

Returns
  • Result Containing:
  • usize
  • or Error if an error is encountered.

Returns the unconfirmed transactions in the transaction pool. Will not return transactions in the stempool.

Returns
  • Result Containing:
  • A vector of PoolEntry
  • or Error if an error is encountered.

Push new transaction to our local transaction pool.

Arguments
  • tx - the Grin transaction to push.
  • fluff - boolean to bypass Dandelion relay.
Returns
  • Result Containing:
  • Ok(()) if the transaction was pushed successfully
  • or Error if an error is encountered.

Trait Implementations

Networked version of Foreign::get_header. Read more

Networked version of Foreign::get_block. Read more

Networked version of Foreign::get_version. Read more

Networked version of Foreign::get_tip. Read more

Networked version of Foreign::get_kernel. Read more

Networked version of Foreign::get_outputs. Read more

Networked version of Foreign::get_pmmr_indices. Read more

Networked version of Foreign::get_pool_size. Read more

Networked version of Foreign::get_stempool_size. Read more

Networked version of Foreign::push_transaction. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

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

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

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

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

Calls U::from(self).

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

Given ptr, which was obtained from a prior call to Self::borrow(), return a value with the same nominal lifetime which is guaranteed to survive mutations to Self. Read more

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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

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