Aim to be easier for clients to use, because to do peer
discovery we must act as a client to other servers.
Split out JSON session concept from the asyncio protocol
concept. This makes the JSON RPC support more easily
testable and usable as a stand-alone library.
In addition, support JSON RPC v1 and v2, and auto-detection
of peer's version.
Apart from the flush on shutdown and the flush when caught up,
neither of which matter, this makes flushes asynchronous.
Also, block processing for reorgs is now asynchronous.
This also removes the FORCE_REORG debug envvar; I want to
put that into the RPC interface.
Closes#102
When the number of sessions reaches MAX_SESSIONS, which defaults
to 1,000, turn off TCP and SSL listening sockets to prevent new
connections. When the session count falls below a low watermark,
currently 90% of MAX_SESSIONS, the listening sockets will be re-opened.
Helps prevent DoS and limit open file usage.
Bug fix: do not start serving paused connections until the buffer
socket is sufficiently drained. Also, loop.
Move session logging code to protocol.py from electrum_rpc.py
Use it for periodic logging controlled by envvar LOG_SESSIONS
For each session, track sent transaction stats and show that
per-session instead of errors
Daemon URLs can be comma-separated in the DAEMON_URL env var.
Surrounding whitespace is stripped.
http:// is preprended if missing.
The coin's default port is supplied if missing.
A trailing / is supplied if missing.
Closes#33