Commit graph

28 commits

Author SHA1 Message Date
Calin Culianu
46b670d813 storage wip 2019-11-29 14:42:17 +02:00
Calin Culianu
7f13c60ece
nits 2019-11-26 22:43:30 +02:00
Calin Culianu
cc8ce73c5a
Made bitcoind communication more efficient by use of ParseHexFast
When reading data from bitcoind, we can assume the hex data it gives us
is good and there is no need to validate on a per-character basis.

Thus, we use ParseHexFast to shave off cpu cycles (it's like 6x faster
than Qt's fromHex()).

This, along with the Util::ToHexFast() (which is 60% faster than
QByteArray::toHex()), will be used in performance critical code.
2019-11-26 22:04:45 +02:00
Calin Culianu
50ee0510f3
Added ParseHexFast() to the Util namespace
This hex parser is 5-6x faster than what we were using before, although
it does no real verification that the input is hex digits.  Usable with
results returned from bitcoind, which is never going to be
malicious/malformed and thus we can rely on this non-checking hex
parser for the performance it offers (at the expense of verification).
2019-11-26 21:01:31 +02:00
Calin Culianu
b8f5ff5fa2 Compile fixup for windows 2019-11-25 23:13:06 +02:00
Calin Culianu
0eb50606b9
Added "CtlTask" mechanism to Controller class, plus nits & refactoring
This is more complex than what we had before -- but is more concurrent
and is more production-ready -- it can deal with failures better and now
we also poll bitcoind for new headers.

Still probably can be optimized somehwat -- but getting there!
2019-11-25 22:34:11 +02:00
Calin Culianu
d7e0ba16db
fixup for error parsing integer id: 1000000.. oops. 2019-11-19 10:44:51 +02:00
Calin Culianu
45e12158db
Added process function to controller, and hooks for bitcoind when ready
Also added the "Fatal" logging class which logs as Error but then
schedules an app exit when invoked.  Only to be used for truly terrible
errors.
2019-11-18 08:29:33 +02:00
Calin Culianu
c0ea7f75a0
Refactored things, added "Controller" class
Controller will manage BitcoinD and perhaps synching to bitcoind. It can
"see" all the servers as well as bitcoind.

Also refactored things a little bit and added some more startup sanity
checks.
2019-11-18 00:21:34 +02:00
Calin Culianu
7a00bb94fb
Added some preliminary skeleton of message processing
Still not sure how I will design this..
2019-11-13 01:52:15 +02:00
Calin Culianu
7c5cfb8993
More nits and cleanup.
I'm getting a little OCD here..  but it's good. :)
2019-11-12 11:29:45 +02:00
Calin Culianu
c0ad6ebefe
more C++ template wizardry 2019-11-12 04:37:34 +02:00
Calin Culianu
46c569ff97 some c++ wizardry to try out packaged_task and futures 2019-11-12 03:04:49 +02:00
Calin Culianu
0d0f41c2f5
Changed the way timestamps are printed in the log 2019-11-11 11:55:10 +02:00
Calin Culianu
b2b2509f25
Got HttpConnection working and talking to bitcoind
It works!  I still haven't figured out how to provoke the dreaded
"Workdepth exceeded" error .. but we pretty much drop the connection
anyway on anything too unexpected from bitcoind.

When the bitcoind manager class is written it will back off and try
again if too many disconnects happen.

For now though, the code we have is fast and works well against
bitcoind.
2019-11-11 00:22:31 +02:00
Calin Culianu
45daaf6e91
some nits 2019-11-09 21:14:07 +02:00
Calin Culianu
cd643e7323
Made Message::Id type a std::variant
I restricted the possible underlying types it can contain down to
qint64, QString, and nullptr_t. This should make it more type safe since
we don't want it to inadvertently end up holding lists or maps
(previously it was a straight up QVariant).

It has a conversion to QVariant so it should work nicely.
2019-11-09 01:55:48 +02:00
Calin Culianu
386383d6d4 Made our JSON-RPC 2.0 implementation more closely match the spec
- It's still a little more restrictive than the spec allows -- doesn't
like non-positive-int 'id'
- We not made the shuffle.spec status report back 'notifications' to the
client rather than repeated 'result' messages (as those would be out of
spec). The first response to a 'shuffle.spec' request is either
result="pending", result="accepted", or an error response
- Subsequent shuffle.spec status changes come as a method notification
for "shuffle.spec" with params=["accepted"] or params=["some error
message"]

Overall I think our bare bones JSON-RPC will at least not break now as
interop with other impls.
2019-05-06 14:34:42 +03:00
Calin Culianu
31b891c006 hooked controller object in to app startup 2019-05-04 06:00:01 +03:00
Calin Culianu
2547dc35cb Added SysLogger for -S option which actually uses unix syslog()
On Windows it still prints to console, however (without timestamps).

Note that syslog mode doesn't produce any debug output even if -d is
specified (at least on macOS) -- probably the sysadmin needs to
enable debug logging.
2019-04-27 16:00:58 +03:00
Calin Culianu
5ccef909af Nits and refactoring of RunInThreads app exit handling 2019-04-27 14:55:10 +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
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
5b9161baba Fixed a crash if using Debug() and no qApp 2019-04-25 10:33:38 +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
57148960c4 Added some command line options and a command line parser 2019-04-23 23:26:07 +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