pub struct Server<V: Vm> {
    pub vm: Arc<RwLock<V>>,
    pub process_metrics: Arc<RwLock<Registry>>,
    pub stop_ch: Sender<()>,
}

Fields§

§vm: Arc<RwLock<V>>

Underlying Vm implementation.

§process_metrics: Arc<RwLock<Registry>>

Subnet Prometheus process metrics.

§stop_ch: Sender<()>

Stop channel broadcast producer.

Implementations§

source§

impl<V: Vm> Server<V>

source

pub fn new(vm: V, stop_ch: Sender<()>) -> Self

Trait Implementations§

source§

impl<V> Vm for Server<V>where V: Vm + Send + Sync + 'static,

source§

fn create_handlers<'life0, 'async_trait>( &'life0 self, _req: Request<Empty> ) -> Pin<Box<dyn Future<Output = Result<Response<CreateHandlersResponse>, Status>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Creates the HTTP handlers for custom chain network calls. This creates and exposes handlers that the outside world can use to communicate with the chain. Each handler has the path:

Returns a mapping from [extension]s to HTTP handlers. Each extension can specify how locking is managed for convenience.

For example, if this VM implements an account-based payments system, it have an extension called accounts, where clients could get information about their accounts.

source§

fn create_static_handlers<'life0, 'async_trait>( &'life0 self, _req: Request<Empty> ) -> Pin<Box<dyn Future<Output = Result<Response<CreateStaticHandlersResponse>, Status>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Creates the HTTP handlers for custom VM network calls.

This creates and exposes handlers that the outside world can use to communicate with a static reference to the VM. Each handler has the path: [Address of node]/ext/VM/[VM ID]/[extension]

Returns a mapping from [extension]s to HTTP handlers.

Each extension can specify how locking is managed for convenience.

For example, it might make sense to have an extension for creating genesis bytes this VM can interpret.

source§

fn get_block<'life0, 'async_trait>( &'life0 self, req: Request<GetBlockRequest> ) -> Pin<Box<dyn Future<Output = Result<Response<GetBlockResponse>, Status>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Attempt to load a block.

If the block does not exist, an empty GetBlockResponse is returned with an error code.

It is expected that blocks that have been successfully verified should be returned correctly. It is also expected that blocks that have been accepted by the consensus engine should be able to be fetched. It is not required for blocks that have been rejected by the consensus engine to be able to be fetched.

ref: https://pkg.go.dev/github.com/ava-labs/avalanchego/snow/engine/snowman/block#Getter

source§

fn initialize<'life0, 'async_trait>( &'life0 self, req: Request<InitializeRequest> ) -> Pin<Box<dyn Future<Output = Result<Response<InitializeResponse>, Status>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

source§

fn shutdown<'life0, 'async_trait>( &'life0 self, _req: Request<Empty> ) -> Pin<Box<dyn Future<Output = Result<Response<Empty>, Status>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

source§

fn build_block<'life0, 'async_trait>( &'life0 self, _req: Request<BuildBlockRequest> ) -> Pin<Box<dyn Future<Output = Result<Response<BuildBlockResponse>, Status>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

source§

fn parse_block<'life0, 'async_trait>( &'life0 self, req: Request<ParseBlockRequest> ) -> Pin<Box<dyn Future<Output = Result<Response<ParseBlockResponse>, Status>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

source§

fn set_state<'life0, 'async_trait>( &'life0 self, req: Request<SetStateRequest> ) -> Pin<Box<dyn Future<Output = Result<Response<SetStateResponse>, Status>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

source§

fn set_preference<'life0, 'async_trait>( &'life0 self, req: Request<SetPreferenceRequest> ) -> Pin<Box<dyn Future<Output = Result<Response<Empty>, Status>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

source§

fn health<'life0, 'async_trait>( &'life0 self, _req: Request<Empty> ) -> Pin<Box<dyn Future<Output = Result<Response<HealthResponse>, Status>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

source§

fn version<'life0, 'async_trait>( &'life0 self, _req: Request<Empty> ) -> Pin<Box<dyn Future<Output = Result<Response<VersionResponse>, Status>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

source§

fn connected<'life0, 'async_trait>( &'life0 self, req: Request<ConnectedRequest> ) -> Pin<Box<dyn Future<Output = Result<Response<Empty>, Status>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

source§

fn disconnected<'life0, 'async_trait>( &'life0 self, req: Request<DisconnectedRequest> ) -> Pin<Box<dyn Future<Output = Result<Response<Empty>, Status>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

source§

fn app_request<'life0, 'async_trait>( &'life0 self, req: Request<AppRequestMsg> ) -> Pin<Box<dyn Future<Output = Result<Response<Empty>, Status>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

source§

fn app_request_failed<'life0, 'async_trait>( &'life0 self, req: Request<AppRequestFailedMsg> ) -> Pin<Box<dyn Future<Output = Result<Response<Empty>, Status>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

source§

fn app_response<'life0, 'async_trait>( &'life0 self, req: Request<AppResponseMsg> ) -> Pin<Box<dyn Future<Output = Result<Response<Empty>, Status>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

source§

fn app_gossip<'life0, 'async_trait>( &'life0 self, req: Request<AppGossipMsg> ) -> Pin<Box<dyn Future<Output = Result<Response<Empty>, Status>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

source§

fn block_verify<'life0, 'async_trait>( &'life0 self, req: Request<BlockVerifyRequest> ) -> Pin<Box<dyn Future<Output = Result<Response<BlockVerifyResponse>, Status>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

source§

fn block_accept<'life0, 'async_trait>( &'life0 self, req: Request<BlockAcceptRequest> ) -> Pin<Box<dyn Future<Output = Result<Response<Empty>, Status>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

source§

fn block_reject<'life0, 'async_trait>( &'life0 self, req: Request<BlockRejectRequest> ) -> Pin<Box<dyn Future<Output = Result<Response<Empty>, Status>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

source§

fn get_ancestors<'life0, 'async_trait>( &'life0 self, _req: Request<GetAncestorsRequest> ) -> Pin<Box<dyn Future<Output = Result<Response<GetAncestorsResponse>, Status>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

source§

fn batched_parse_block<'life0, 'async_trait>( &'life0 self, _req: Request<BatchedParseBlockRequest> ) -> Pin<Box<dyn Future<Output = Result<Response<BatchedParseBlockResponse>, Status>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

source§

fn gather<'life0, 'async_trait>( &'life0 self, _req: Request<Empty> ) -> Pin<Box<dyn Future<Output = Result<Response<GatherResponse>, Status>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

source§

fn cross_chain_app_request<'life0, 'async_trait>( &'life0 self, req: Request<CrossChainAppRequestMsg> ) -> Pin<Box<dyn Future<Output = Result<Response<Empty>, Status>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

source§

fn cross_chain_app_request_failed<'life0, 'async_trait>( &'life0 self, req: Request<CrossChainAppRequestFailedMsg> ) -> Pin<Box<dyn Future<Output = Result<Response<Empty>, Status>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

source§

fn cross_chain_app_response<'life0, 'async_trait>( &'life0 self, req: Request<CrossChainAppResponseMsg> ) -> Pin<Box<dyn Future<Output = Result<Response<Empty>, Status>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

source§

fn state_sync_enabled<'life0, 'async_trait>( &'life0 self, _req: Request<Empty> ) -> Pin<Box<dyn Future<Output = Result<Response<StateSyncEnabledResponse>, Status>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

source§

fn get_ongoing_sync_state_summary<'life0, 'async_trait>( &'life0 self, _req: Request<Empty> ) -> Pin<Box<dyn Future<Output = Result<Response<GetOngoingSyncStateSummaryResponse>, Status>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

source§

fn parse_state_summary<'life0, 'async_trait>( &'life0 self, _req: Request<ParseStateSummaryRequest> ) -> Pin<Box<dyn Future<Output = Result<Response<ParseStateSummaryResponse>, Status>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

source§

fn get_state_summary<'life0, 'async_trait>( &'life0 self, _req: Request<GetStateSummaryRequest> ) -> Pin<Box<dyn Future<Output = Result<Response<GetStateSummaryResponse>, Status>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

source§

fn get_last_state_summary<'life0, 'async_trait>( &'life0 self, _req: Request<Empty> ) -> Pin<Box<dyn Future<Output = Result<Response<GetLastStateSummaryResponse>, Status>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

source§

fn state_summary_accept<'life0, 'async_trait>( &'life0 self, _req: Request<StateSummaryAcceptRequest> ) -> Pin<Box<dyn Future<Output = Result<Response<StateSummaryAcceptResponse>, Status>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

source§

fn verify_height_index<'life0, 'async_trait>( &'life0 self, _req: Request<Empty> ) -> Pin<Box<dyn Future<Output = Result<Response<VerifyHeightIndexResponse>, Status>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

source§

fn get_block_id_at_height<'life0, 'async_trait>( &'life0 self, _req: Request<GetBlockIdAtHeightRequest> ) -> Pin<Box<dyn Future<Output = Result<Response<GetBlockIdAtHeightResponse>, Status>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,

Auto Trait Implementations§

§

impl<V> !RefUnwindSafe for Server<V>

§

impl<V> Send for Server<V>where V: Send + Sync,

§

impl<V> Sync for Server<V>where V: Send + Sync,

§

impl<V> Unpin for Server<V>

§

impl<V> !UnwindSafe for Server<V>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · 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, U> Into<U> for Twhere U: From<T>,

const: unstable · 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> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
§

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

§

fn vzip(self) -> V

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