peer property
We use a Peer here--which implements both Server and Client sides of a Remote Procedure Call (RPC) interface--to communicate with an ElectrumX Ravencoin server. We do so because we need:
-
the Client side for the basic ability to call 'procedures' on the remote server (e.g. 'blockchain.scripthash.get_balance');
-
the Server side so that when we can subscribe to an ongoing stream of updates (e.g. 'blockchain.headers.subscribe'). The remote server can notify us of an update by calling our registered 'procedures'.
The ElectrumX specification requires that notifications from the server use procedure names that match the initiating subscribe call. For example:
We can start a subscription by calling blockchain.scripthash.subscribe
and the server will subsequently notify us uf status changes by
calling this client's matching blockchain.scripthash.subscribe
procedure.
Note that the BaseClient class does not implement subscriptions.
Implementation
late rpc.Peer peer;