pub struct ElectrumServer<Blockchain: BlockchainInterface> {
pub chain: Arc<Blockchain>,
pub address_cache: Arc<AddressCache<KvDatabase>>,
pub clients: HashMap<u32, Arc<Client>>,
pub message_receiver: UnboundedReceiver<Message>,
pub message_transmitter: UnboundedSender<Message>,
pub client_addresses: HashMap<Hash, Arc<Client>>,
pub block_filters: Option<Arc<NetworkFilters<FlatFiltersStore>>>,
pub node_interface: 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<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.
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: UnboundedReceiver<Message>The message_receiver receive messages and handles them.
message_transmitter: UnboundedSender<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: NodeInterfaceAn 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>
impl<Blockchain: BlockchainInterface> ElectrumServer<Blockchain>
pub async fn new( address_cache: Arc<AddressCache<KvDatabase>>, chain: Arc<Blockchain>, block_filters: Option<Arc<NetworkFilters<FlatFiltersStore>>>, node_interface: NodeInterface, ) -> Result<ElectrumServer<Blockchain>, Box<dyn Error>>
Sourcepub async fn handle_client_request(
&mut self,
client: Arc<Client>,
request: Request,
) -> Result<Value, Error>
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.
pub async fn main_loop(self) -> Result<(), Error>
Auto Trait Implementations§
impl<Blockchain> Freeze for ElectrumServer<Blockchain>
impl<Blockchain> RefUnwindSafe for ElectrumServer<Blockchain>where
Blockchain: RefUnwindSafe,
impl<Blockchain> Send for ElectrumServer<Blockchain>
impl<Blockchain> Sync for ElectrumServer<Blockchain>
impl<Blockchain> Unpin for ElectrumServer<Blockchain>
impl<Blockchain> UnwindSafe for ElectrumServer<Blockchain>where
Blockchain: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more