Struct grin_api::Owner

source ·
pub struct Owner {
    pub chain: Weak<Chain>,
    pub peers: Weak<Peers>,
    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>§peers: Weak<Peers>§sync_state: Weak<SyncState>

Implementations§

source§

impl Owner

source

pub fn new( chain: Weak<Chain>, peers: Weak<Peers>, 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 the sync_state.
§Returns
  • An instance of the Node holding references to the current chain, transaction pool, peers and sync_state.
source

pub fn get_status(&self) -> Result<Status, Error>

Returns various information about the node, the network and the current sync status.

§Returns
  • Result Containing:
  • A Status
  • or Error if an error is encountered.
source

pub fn validate_chain( &self, assume_valid_rangeproofs_kernels: bool ) -> Result<(), Error>

Trigger a validation of the chain state.

§Arguments
  • assume_valid_rangeproofs_kernels - if false, will validate rangeproofs, kernel signatures and sum of kernel excesses. if true, will only validate the sum of kernel excesses should equal the sum of unspent outputs minus total supply.
§Returns
  • Result Containing:
  • Ok(()) if the validation was done successfully
  • or Error if an error is encountered.
source

pub fn compact_chain(&self) -> Result<(), Error>

Trigger a compaction of the chain state to regain storage space.

§Returns
  • Result Containing:
  • Ok(()) if the compaction was done successfully
  • or Error if an error is encountered.
source

pub fn reset_chain_head(&self, hash: String) -> Result<(), Error>

source

pub fn invalidate_header(&self, hash: String) -> Result<(), Error>

source

pub fn get_peers( &self, addr: Option<SocketAddr> ) -> Result<Vec<PeerData>, Error>

Retrieves information about stored peers. If None is provided, will list all stored peers.

§Arguments
  • addr - the ip:port of the peer to get.
§Returns
  • Result Containing:
  • A vector of PeerData
  • or Error if an error is encountered.
source

pub fn get_connected_peers(&self) -> Result<Vec<PeerInfoDisplay>, Error>

Retrieves a list of all connected peers.

§Returns
source

pub fn ban_peer(&self, addr: SocketAddr) -> Result<(), Error>

Bans a specific peer.

§Arguments
  • addr - the ip:port of the peer to ban.
§Returns
  • Result Containing:
  • Ok(()) if the path was correctly set
  • or Error if an error is encountered.
source

pub fn unban_peer(&self, addr: SocketAddr) -> Result<(), Error>

Unbans a specific peer.

§Arguments
  • addr - the ip:port of the peer to unban.
§Returns
  • Result Containing:
  • Ok(()) if the unban was done successfully
  • or Error if an error is encountered.

Trait Implementations§

source§

impl OwnerRpc for Owner

source§

fn get_status(&self) -> Result<Status, Error>

Networked version of Owner::get_status. Read more
source§

fn validate_chain( &self, assume_valid_rangeproofs_kernels: bool ) -> Result<(), Error>

Networked version of Owner::validate_chain. Read more
source§

fn reset_chain_head(&self, hash: String) -> Result<(), Error>

source§

fn invalidate_header(&self, hash: String) -> Result<(), Error>

source§

fn compact_chain(&self) -> Result<(), Error>

Networked version of Owner::compact_chain. Read more
source§

fn get_peers(&self, addr: Option<SocketAddr>) -> Result<Vec<PeerData>, Error>

Networked version of Owner::get_peers. Read more
source§

fn get_connected_peers(&self) -> Result<Vec<PeerInfoDisplay>, Error>

source§

fn ban_peer(&self, addr: SocketAddr) -> Result<(), Error>

Networked version of Owner::ban_peer. Read more
source§

fn unban_peer(&self, addr: SocketAddr) -> Result<(), Error>

Networked version of Owner::unban_peer. Read more

Auto Trait Implementations§

§

impl Freeze for Owner

§

impl !RefUnwindSafe for Owner

§

impl Send for Owner

§

impl Sync for Owner

§

impl Unpin for Owner

§

impl !UnwindSafe for Owner

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.

source§

impl<T> Instrument for T

source§

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

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T> Instrument for T

source§

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

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

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> SafeBorrow<T> for T
where T: ?Sized,

source§

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

impl<T> Same for T

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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.
source§

impl<T> WithSubscriber for T

source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> UnsafeAny for T
where T: Any,