Struct evm_adapters::sputnik::cache::SharedBackend[][src]

pub struct SharedBackend { /* fields omitted */ }
Expand description

A cloneable backend type that shares access to the backend data with all its clones.

This backend type is connected to the BackendHandler via a mpsc channel. The BackendHandlers is spawned on a background thread and listens for incoming commands on the receiver half of the channel. A SharedBackend holds a sender for that channel, which is Clone, so their can be multiple SharedBackends communicating with the same BackendHandler, hence this Backend type is thread safe.

All Backend trait functions are delegated as a BackendRequest via the channel to the BackendHandler. All BackendRequest variants include a sender half of an additional channel that is used by the BackendHandler to send the result of an executed BackendRequest back to SharedBackend.

The BackendHandler holds an ethers Provider to look up missing accounts or storage slots from remote (e.g. infura). It detects duplicate requests from multiple SharedBackends and bundles them together, so that always only one provider request is executed. For example, there are two SharedBackends, A and B, both request the basic account info of account 0xasd9sa7d... at the same time. After the BackendHandler receives the request from A, it sends a new provider request to the provider’s endpoint, then it reads the identical request from B and simply adds it as an additional listener for the request already in progress, instead of sending another one. So that after the provider returns the response all listeners (A and B) get notified.

Implementations

Spawns a new BackendHandler on a background thread that listens for requests from any SharedBackend. Missing values get inserted in the cache.

NOTE: this should be called with Arc<Provider>

Trait Implementations

Gas price. Unused for London.

Origin.

Environmental block hash.

Environmental block number.

Environmental coinbase.

Environmental block timestamp.

Environmental block difficulty.

Environmental block gas limit.

Environmental block base fee.

Environmental chain ID.

Whether account at address exists.

Get basic account information.

Get account code.

Get storage value of address at index.

Get original storage value of address at index, if available.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. 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

Performs the conversion.

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

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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