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
Fields
chain: Weak<Chain>
tx_pool: Weak<RwLock<TransactionPool<B, P>>>
sync_state: Weak<SyncState>
Implementations
sourceimpl<B, P> Foreign<B, P> where
B: BlockChain,
P: PoolAdapter,
impl<B, P> Foreign<B, P> where
B: BlockChain,
P: PoolAdapter,
sourcepub fn new(
chain: Weak<Chain>,
tx_pool: Weak<RwLock<TransactionPool<B, P>>>,
sync_state: Weak<SyncState>
) -> Self
pub fn new(
chain: Weak<Chain>,
tx_pool: Weak<RwLock<TransactionPool<B, P>>>,
sync_state: Weak<SyncState>
) -> Self
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 thesync_state
.
Returns
- An instance of the Node holding references to the current chain, transaction pool, peers and sync_state.
sourcepub fn get_header(
&self,
height: Option<u64>,
hash: Option<Hash>,
commit: Option<String>
) -> Result<BlockHeaderPrintable, Error>
pub fn get_header(
&self,
height: Option<u64>,
hash: Option<Hash>,
commit: Option<String>
) -> Result<BlockHeaderPrintable, Error>
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
- Result Containing:
- A
BlockHeaderPrintable
- or
Error
if an error is encountered.
sourcepub fn get_block(
&self,
height: Option<u64>,
hash: Option<Hash>,
commit: Option<String>
) -> Result<BlockPrintable, Error>
pub fn get_block(
&self,
height: Option<u64>,
hash: Option<Hash>,
commit: Option<String>
) -> Result<BlockPrintable, Error>
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
- Result Containing:
- A
BlockPrintable
- or
Error
if an error is encountered.
sourcepub fn get_version(&self) -> Result<Version, Error>
pub fn get_version(&self) -> Result<Version, Error>
sourcepub fn get_kernel(
&self,
excess: String,
min_height: Option<u64>,
max_height: Option<u64>
) -> Result<LocatedTxKernel, Error>
pub fn get_kernel(
&self,
excess: String,
min_height: Option<u64>,
max_height: Option<u64>
) -> Result<LocatedTxKernel, Error>
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
- Result Containing:
- A
LocatedTxKernel
- or
Error
if an error is encountered.
sourcepub fn get_outputs(
&self,
commits: Option<Vec<String>>,
start_height: Option<u64>,
end_height: Option<u64>,
include_proof: Option<bool>,
include_merkle_proof: Option<bool>
) -> Result<Vec<OutputPrintable>, Error>
pub fn get_outputs(
&self,
commits: Option<Vec<String>>,
start_height: Option<u64>,
end_height: Option<u64>,
include_proof: Option<bool>,
include_merkle_proof: Option<bool>
) -> Result<Vec<OutputPrintable>, Error>
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
- Result Containing:
- An
OutputPrintable
- or
Error
if an error is encountered.
sourcepub fn get_unspent_outputs(
&self,
start_index: u64,
end_index: Option<u64>,
max: u64,
include_proof: Option<bool>
) -> Result<OutputListing, Error>
pub fn get_unspent_outputs(
&self,
start_index: u64,
end_index: Option<u64>,
max: u64,
include_proof: Option<bool>
) -> Result<OutputListing, Error>
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
- Result Containing:
- An
OutputListing
- or
Error
if an error is encountered.
sourcepub fn get_pmmr_indices(
&self,
start_block_height: u64,
end_block_height: Option<u64>
) -> Result<OutputListing, Error>
pub fn get_pmmr_indices(
&self,
start_block_height: u64,
end_block_height: Option<u64>
) -> Result<OutputListing, Error>
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
- Result Containing:
- An
OutputListing
- or
Error
if an error is encountered.
sourcepub fn get_pool_size(&self) -> Result<usize, Error>
pub fn get_pool_size(&self) -> Result<usize, Error>
sourcepub fn get_stempool_size(&self) -> Result<usize, Error>
pub fn get_stempool_size(&self) -> Result<usize, Error>
sourcepub fn push_transaction(
&self,
tx: Transaction,
fluff: Option<bool>
) -> Result<(), Error>
pub fn push_transaction(
&self,
tx: Transaction,
fluff: Option<bool>
) -> Result<(), Error>
Trait Implementations
sourceimpl<B, P> ForeignRpc for Foreign<B, P> where
B: BlockChain,
P: PoolAdapter,
impl<B, P> ForeignRpc for Foreign<B, P> where
B: BlockChain,
P: PoolAdapter,
sourcefn get_header(
&self,
height: Option<u64>,
hash: Option<String>,
commit: Option<String>
) -> Result<BlockHeaderPrintable, ErrorKind>
fn get_header(
&self,
height: Option<u64>,
hash: Option<String>,
commit: Option<String>
) -> Result<BlockHeaderPrintable, ErrorKind>
Networked version of Foreign::get_header. Read more
sourcefn get_block(
&self,
height: Option<u64>,
hash: Option<String>,
commit: Option<String>
) -> Result<BlockPrintable, ErrorKind>
fn get_block(
&self,
height: Option<u64>,
hash: Option<String>,
commit: Option<String>
) -> Result<BlockPrintable, ErrorKind>
Networked version of Foreign::get_block. Read more
sourcefn get_version(&self) -> Result<Version, ErrorKind>
fn get_version(&self) -> Result<Version, ErrorKind>
Networked version of Foreign::get_version. Read more
sourcefn get_kernel(
&self,
excess: String,
min_height: Option<u64>,
max_height: Option<u64>
) -> Result<LocatedTxKernel, ErrorKind>
fn get_kernel(
&self,
excess: String,
min_height: Option<u64>,
max_height: Option<u64>
) -> Result<LocatedTxKernel, ErrorKind>
Networked version of Foreign::get_kernel. Read more
sourcefn get_outputs(
&self,
commits: Option<Vec<String>>,
start_height: Option<u64>,
end_height: Option<u64>,
include_proof: Option<bool>,
include_merkle_proof: Option<bool>
) -> Result<Vec<OutputPrintable>, ErrorKind>
fn get_outputs(
&self,
commits: Option<Vec<String>>,
start_height: Option<u64>,
end_height: Option<u64>,
include_proof: Option<bool>,
include_merkle_proof: Option<bool>
) -> Result<Vec<OutputPrintable>, ErrorKind>
Networked version of Foreign::get_outputs. Read more
sourcefn get_unspent_outputs(
&self,
start_index: u64,
end_index: Option<u64>,
max: u64,
include_proof: Option<bool>
) -> Result<OutputListing, ErrorKind>
fn get_unspent_outputs(
&self,
start_index: u64,
end_index: Option<u64>,
max: u64,
include_proof: Option<bool>
) -> Result<OutputListing, ErrorKind>
Networked version of Foreign::get_unspent_outputs. Read more
sourcefn get_pmmr_indices(
&self,
start_block_height: u64,
end_block_height: Option<u64>
) -> Result<OutputListing, ErrorKind>
fn get_pmmr_indices(
&self,
start_block_height: u64,
end_block_height: Option<u64>
) -> Result<OutputListing, ErrorKind>
Networked version of Foreign::get_pmmr_indices. Read more
sourcefn get_pool_size(&self) -> Result<usize, ErrorKind>
fn get_pool_size(&self) -> Result<usize, ErrorKind>
Networked version of Foreign::get_pool_size. Read more
sourcefn get_stempool_size(&self) -> Result<usize, ErrorKind>
fn get_stempool_size(&self) -> Result<usize, ErrorKind>
Networked version of Foreign::get_stempool_size. Read more
sourcefn get_unconfirmed_transactions(&self) -> Result<Vec<PoolEntry>, ErrorKind>
fn get_unconfirmed_transactions(&self) -> Result<Vec<PoolEntry>, ErrorKind>
Networked version of Foreign::get_unconfirmed_transactions. Read more
sourcefn push_transaction(
&self,
tx: Transaction,
fluff: Option<bool>
) -> Result<(), ErrorKind>
fn push_transaction(
&self,
tx: Transaction,
fluff: Option<bool>
) -> Result<(), ErrorKind>
Networked version of Foreign::push_transaction. Read more
Auto Trait Implementations
impl<B, P> !RefUnwindSafe for Foreign<B, P>
impl<B, P> Send for Foreign<B, P>
impl<B, P> Sync for Foreign<B, P>
impl<B, P> Unpin for Foreign<B, P>
impl<B, P> !UnwindSafe for Foreign<B, P>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> SafeBorrow<T> for T where
T: ?Sized,
impl<T> SafeBorrow<T> for T where
T: ?Sized,
fn borrow_replacement(ptr: &T) -> &T
fn borrow_replacement(ptr: &T) -> &T
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
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more