pub struct ElectrumServer<Blockchain: BlockchainInterface> {
    pub chain: Arc<Blockchain>,
    pub address_cache: Arc<RwLock<AddressCache<KvDatabase>>>,
    pub tcp_listener: Arc<TcpListener>,
    pub clients: HashMap<u32, Arc<Client>>,
    pub message_receiver: Receiver<Message>,
    pub message_transmitter: Sender<Message>,
    pub client_addresses: HashMap<Hash, Arc<Client>>,
    pub block_filters: Option<Arc<NetworkFilters<FlatFiltersStore>>>,
    pub node_interface: Arc<NodeInterface>,
    pub addresses_to_scan: Vec<ScriptBuf>,
}

Fields§

§chain: Arc<Blockchain>

The blockchain backend we are using. This will be used to query blockchain information and broadcast transactions.

§address_cache: Arc<RwLock<AddressCache<KvDatabase>>>

The address cache is used to store addresses and transactions, like a watch-only wallet, but it is adapted to the electrum protocol.

§tcp_listener: Arc<TcpListener>

The TCP listener is used to accept new connections to our server.

§clients: HashMap<u32, Arc<Client>>

The clients are the clients connected to our server, we keep track of them using a unique id.

§message_receiver: Receiver<Message>

The message_receiver receive messages and handles them.

§message_transmitter: Sender<Message>

The message_transmitter is used to send requests from clients or notifications like new or dropped clients

§client_addresses: HashMap<Hash, Arc<Client>>

The client_addresses is used to keep track of the addresses of each client. We keep the script_hash and which client has it, so we can notify the clients when a new transaction is received.

§block_filters: Option<Arc<NetworkFilters<FlatFiltersStore>>>

A Arc-ed copy of the block filters backend that we can use to check if a block contains a transaction that we are interested in.

§node_interface: Arc<NodeInterface>

An interface to a running node, used to broadcast transactions and request blocks.

§addresses_to_scan: Vec<ScriptBuf>

A list of addresses that we’ve just learned about and need to rescan for transactions.

We accumulate those addresses here and then periodically scan, since a wallet will often send multiple addresses, but in different requests.

Implementations§

source§

impl<Blockchain: BlockchainInterface> ElectrumServer<Blockchain>

source

pub async fn new( address: String, address_cache: Arc<RwLock<AddressCache<KvDatabase>>>, chain: Arc<Blockchain>, block_filters: Option<Arc<NetworkFilters<FlatFiltersStore>>>, node_interface: Arc<NodeInterface> ) -> Result<ElectrumServer<Blockchain>, Box<dyn Error>>

source

pub async fn handle_client_request( &mut self, client: Arc<Client>, request: Request ) -> Result<Value, Error>

Handle a request from a client. All methods are defined in the electrum protocol.

source

pub async fn main_loop(self) -> Result<(), Error>

Auto Trait Implementations§

§

impl<Blockchain> !RefUnwindSafe for ElectrumServer<Blockchain>

§

impl<Blockchain> Send for ElectrumServer<Blockchain>where Blockchain: Send + Sync,

§

impl<Blockchain> Sync for ElectrumServer<Blockchain>where Blockchain: Send + Sync,

§

impl<Blockchain> Unpin for ElectrumServer<Blockchain>

§

impl<Blockchain> !UnwindSafe for ElectrumServer<Blockchain>

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,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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, U> Into<U> for Twhere 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> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
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.
source§

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

Performs the conversion.
source§

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

source§

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