Commit graph

29 commits

Author SHA1 Message Date
Calin Culianu
faeb64207f Finally.. finished refactoring out the RPC bits.
Now we can re-use the RPC method<->result code in the TcpServer side
which will face wallets.  Phew!  Took me long enough!

It's a minimal JSON-RPC protocol impl.. but it'll do.

The 1 nice bit is the Schema spec I came up with which more-or-less
works well enough as a first-pass validatior.

Further passes are needed in interested client code, but the initial
pass validation can be done in a thread so as to not waste the main
thread's time validating json or dict key presence/absense. Yay.
2019-04-30 19:21:47 +03:00
Calin Culianu
5e4aa2d9f9 renamed boilerplate_disconnect to disconnect 2019-04-30 17:09:07 +03:00
Calin Culianu
4bd954a390 intermediate commit.. about to refactor exclient more 2019-04-30 10:01:21 +03:00
Calin Culianu
c28b9221e3 renamed AbstractClient -> AbstractConnection 2019-04-29 20:52:40 +03:00
Calin Culianu
f6ac87c4b2 Refactored TcpServer's client to use AbstractClient
Yay.. code is more reusable now in general.  Was a good exercise.

Todo: refactor the JsonRPC stuff to be generic and reusable.
2019-04-28 14:59:01 +03:00
Calin Culianu
bc8144ea84 Refactorings continue...
TcpServer now uses the ThreadObjectMixin.. yay.

Plus misc other cleanup.

Now I can implement the client..
2019-04-28 11:59:14 +03:00
Calin Culianu
9fc0343b45 Refactored out the worker-thread paradigm thing we use
Into a pure mixin class called "ThreadObjectMixin".

TODO: make the TcpServer also use this mixin.
2019-04-28 10:27:17 +03:00
Calin Culianu
7e16896844 refactored EXClient into AbstractClient and EXClient 2019-04-28 01:54:54 +03:00
Calin Culianu
7c8a118185 factored out AbstractClient. About to refactor EXClient to use it. 2019-04-28 00:09:48 +03:00
Calin Culianu
a11de1d992 oops. misconnected a signal. fixed. 2019-04-27 13:36:30 +03:00
Calin Culianu
3f49dce1db Added some small goodies
- Util::RunInThread to run a lambda in a thread
- App exit handling cleanup
- EXMgr uses an id for clients now
- EXMgr keeps track of lagging clients
- EXMgr more aggressive with reconnects if no valid exclients
- Nits and refactorings and misc. cleanup
2019-04-27 12:38:50 +03:00
Calin Culianu
19a230d464 minor nit to avoid a signal race condition 2019-04-26 20:35:36 +03:00
Calin Culianu
2477a7a8a3 Added initial TcpServer stub implementation
- Already supports listening on as many sockets as you wish
- Each listening server has its own thread
- Will implement later: SSL server

Also refactored code a bit, created the generic "Controller" class, made
EXMgr and SrvMgr inherit from it.

ToDo: Figure out workflow for connections and clients, model client
sessions, etc.
2019-04-26 08:47:46 +03:00
Calin Culianu
d3cc2ff830 Tweaks
- Only send server.ping on idle >1min (previously we sent
unconditionally once a minute)

- Added __attrubute__ format stuff to the printf-like log functions

- Small nit
2019-04-24 12:44:01 +03:00
Calin Culianu
3721baf3bb Moved reqid generation from EXClient to EXMgr
This is probably where it belongs. Will allow us to track requests to the
ElectrumX server better as we implement more of this server.
2019-04-24 10:57:11 +03:00
Calin Culianu
92da67a602 tweak 2019-04-24 08:10:37 +03:00
Calin Culianu
1a06e27f94 Defense against malicious EX server. Disallow filling our buffers indef. 2019-04-24 08:07:47 +03:00
Calin Culianu
dca9c804b3 defensive programming tweak 2019-04-24 07:58:41 +03:00
Calin Culianu
2faacb2c6e Got SSL working by turning off verify certs. We use SSL now preferentially if available 2019-04-24 07:54:46 +03:00
Calin Culianu
1d44070d61 tweak to remember EXClient bad status beyond disconnect 2019-04-24 07:01:28 +03:00
Calin Culianu
68e5d9f7d0 Hardened socket code a bit for EXClient 2019-04-24 06:54:32 +03:00
Calin Culianu
027f0f1b44 renamed EXClient 'keepAliveTimer' -> 'pingTimer' 2019-04-23 23:55:07 +03:00
Calin Culianu
6b4d41ea98 tweak 2019-04-23 23:31:14 +03:00
Calin Culianu
0c51a34190 Fixups to fix crash
We weren't exactly thread safe. Fixed to not touch socket from main
thread. Also documented what should be called from which thread.
Hopefully we are solid now.
2019-04-23 21:51:53 +03:00
Calin Culianu
3aec346c74 Tweak to prevent leaking idMethodMap if bad server 2019-04-23 19:20:48 +03:00
Calin Culianu
2db4d09705 implemented checkClients (maintain EXClients) 2019-04-23 18:49:36 +03:00
Calin Culianu
58461e7890 implemented 3 electrum x protocol commands. getting there. 2019-04-23 16:24:18 +03:00
Calin Culianu
4637012e22 Added more EXClient stuff 2019-04-23 12:36:51 +03:00
Calin Culianu
62101beeac Initial revision. Just laying out a skeleton to build on. 2019-04-23 02:33:16 +03:00