Struct grin_servers::Server

source ·
pub struct Server {
    pub config: ServerConfig,
    pub p2p: Arc<Server>,
    pub chain: Arc<Chain>,
    pub tx_pool: ServerTxPool,
    pub sync_state: Arc<SyncState>,
    pub stop_state: Arc<StopState>,
    /* private fields */
}
Expand description

Grin server holding internal structures.

Fields§

§config: ServerConfig

server config

§p2p: Arc<Server>

handle to our network server

§chain: Arc<Chain>

data store access

§tx_pool: ServerTxPool

in-memory transaction pool

§sync_state: Arc<SyncState>

Whether we’re currently syncing

§stop_state: Arc<StopState>

Stop flag

Implementations§

source§

impl Server

source

pub fn start<F>( config: ServerConfig, logs_rx: Option<Receiver<LogEntry>>, info_callback: F, stop_state: Option<Arc<StopState>>, api_chan: &'static mut (Sender<()>, Receiver<()>) ) -> Result<(), Error>

Instantiates and starts a new server. Optionally takes a callback for the server to send an ARC copy of itself, to allow another process to poll info about the server status

source

pub fn new( config: ServerConfig, stop_state: Option<Arc<StopState>>, api_chan: &'static mut (Sender<()>, Receiver<()>) ) -> Result<Server, Error>

Instantiates a new server associated with the provided future reactor.

source

pub fn connect_peer(&self, addr: PeerAddr) -> Result<(), Error>

Asks the server to connect to a peer at the provided network address.

source

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

Ping all peers, mostly useful for tests to have connected peers share their heights

source

pub fn peer_count(&self) -> u32

Number of peers

source

pub fn start_stratum_server(&self, config: StratumServerConfig)

Start a minimal “stratum” mining service on a separate thread

source

pub fn start_test_miner( &self, wallet_listener_url: Option<String>, stop_state: Arc<StopState> )

Start mining for blocks internally on a separate thread. Relies on internal miner, and should only be used for automated testing. Burns reward if wallet_listener_url is ‘None’

source

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

The chain head

source

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

The head of the block header chain

source

pub fn protocol_version() -> ProtocolVersion

The p2p layer protocol version for this node.

source

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

Returns a set of stats about this server. This and the ServerStats structure can be updated over time to include any information needed by tests or other consumers

source

pub fn stop(self)

Stop the server.

source

pub fn pause(&self)

Pause the p2p server.

source

pub fn resume(&self)

Resume p2p server. TODO - We appear not to resume the p2p server (peer connections) here?

source

pub fn stop_test_miner(&self, stop: Arc<StopState>)

Stops the test miner without stopping the p2p layer

Auto Trait Implementations§

§

impl Freeze for Server

§

impl !RefUnwindSafe for Server

§

impl Send for Server

§

impl Sync for Server

§

impl Unpin for Server

§

impl !UnwindSafe for Server

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,