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>
impl<Blockchain: BlockchainInterface> ElectrumServer<Blockchain>
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>>
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.