Commit graph

61 commits

Author SHA1 Message Date
Calin Culianu
7c63bba5d0 nits 2019-12-02 09:43:03 +02:00
Calin Culianu
76d0505323
Nits, refactorings, and tweaks
Cleaned up the code for BlockProc and created the HashX class

Plus made some of the PreProcessedBlock fields be more type-safe (using
std::optional)
2019-12-02 01:29:24 +02:00
Calin Culianu
e9d3991ded
WIP - added PreProcessedBlock
The PreProcessedBlock is intended to be a somewhat munged/mogrified form
of a CBlock which is somewhat ready for a db insert.

This data will get passed onto the Controller thread which will set
everything up to commit the SH history, header, etc to the db.

Did some initial testing and it's pretty fast and also.. I think it's
correct (as in I'm collating the data correctly).

TODO: Some more testing.
2019-12-01 22:36:19 +02:00
Calin Culianu
16a2e195c4
Nits/refactoring for the BTC::Deserialize* functions
I made them all less boilerplatey and use templates.  yay!
2019-12-01 15:22:12 +02:00
Calin Culianu
4c8f5d0f9b tweaks 2019-12-01 01:10:54 +02:00
Calin Culianu
06ab90b157 nits 2019-12-01 00:50:42 +02:00
Calin Culianu
a8e6703c38 tweaks 2019-12-01 00:43:03 +02:00
Calin Culianu
06cbe1321b tweaks / wip 2019-12-01 00:20:15 +02:00
Calin Culianu
c3091c0d99 tweaks 2019-11-30 23:33:30 +02:00
Calin Culianu
cbaea7a276 went back to getblockheader header dl for testing 2019-11-30 22:18:12 +02:00
Calin Culianu
5c9ecd9c08 Implemented different parallelism: stride style breakup of the download space between tasks 2019-11-30 22:07:35 +02:00
Calin Culianu
bea420355b wip 2019-11-30 12:29:32 +02:00
Calin Culianu
a7293a9939
Potential bug fixed: Added protection from connecting to wrong bitcoind
We now save the "chain" variable to the meta table.  We also panic if
the headers we are reading from bitcoind are behind what we have (todo:
handle this elegantly if there actually was a reorg?)
2019-11-30 01:33:27 +02:00
Calin Culianu
5842c44a79
Nits, refactorings + added shared HeaderVerifier that lives in Storage 2019-11-30 00:42:33 +02:00
Calin Culianu
46b670d813 storage wip 2019-11-29 14:42:17 +02:00
Calin Culianu
e9d432f5e7
C++ template magic - newTask factory function
Templates are fun.  Decided to reduce boilerplate by making task
creation inside the Controller class be done by a template member
function which acts like a task factory.  It surrounds the construction
of the task with some boilerplate (namely, inserting the task in the
tasks map, connecting an optional errored signal, and starting the
task).
2019-11-27 20:32:50 +02:00
Calin Culianu
c499e1a1b3
Made the "upToDate" slot that creates srvmgr fire only once
Via shared_ptr tricks, it only fires once in the interests of
efficiency. After the server is created the connection is disconnected.
2019-11-27 14:46:17 +02:00
Calin Culianu
6df916565a
Made app only start listening for client connections after initial sync
Also in this commit various nits and subtle bugs prevented.

Refactored the 'Stats' mechanism to return a generic QVariant rather
than QVariantMap, which is more flexible.

Misc. other nits.
2019-11-27 14:07:09 +02:00
Calin Culianu
0bf3d4e2ae
refactor ChainInfo into its own struct 2019-11-27 12:12:16 +02:00
Calin Culianu
bb1d371d2e
Use getblockchaininfo rather than getblockcount, and more
We now query more information initially when synching, which can be
useful.

We also deal with initial block download by retrying every minute

and other miscellany
2019-11-27 12:03:12 +02:00
Calin Culianu
1743a4728e
Some nits. Use of an unordered_map and static_assert, simplified map.emplace, show hdr dl pct 2019-11-27 02:38:39 +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
d9f335f1d4
memory/vector usage nits 2019-11-26 12:29:27 +02:00
Calin Culianu
9f2ba890f4
Tuned concurrency even better -- got performane to beat old scheme!
Also in this commit: small nits
2019-11-26 00:18:28 +02:00
Calin Culianu
b41957b811
improved parallelism / bitcoind utilization 2019-11-25 23:34:04 +02:00
Calin Culianu
e6642fa87a
nits 2019-11-25 22:56:46 +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
a34681aa31
Added header download to our test code
It's pretty fast. Downloads all headers in 120 seconds or so.  Keeps
them all in memory.
2019-11-24 22:28:26 +02:00
Calin Culianu
b8a507615d
nit 2019-11-24 18:51:22 +02:00
Calin Culianu
7fa213e095
Added "bitcoind is warming up..." messaging
Just a small nit, really.
2019-11-24 18:23:34 +02:00
Calin Culianu
b823f97397
nits 2019-11-19 12:33:50 +02:00
Calin Culianu
abc1aaabd0
tweaks to header dl test code 2019-11-19 10:59:53 +02:00
Calin Culianu
d7e0ba16db
fixup for error parsing integer id: 1000000.. oops. 2019-11-19 10:44:51 +02:00
Calin Culianu
4b59e2233a Increased parallelism for the header sync
Set maxcur to 16, spinning up 3 bitcoind threads.

Seems to have brought header synch down from 170s to 71s on my mainnet
node here locally. Not bad!

Also fixed a bug where selecting bitcoind nodes was failing if >2 nodes.
2019-11-19 01:58:30 +02:00
Calin Culianu
819fa47990 wip 2019-11-18 21:22:30 +02:00
Calin Culianu
9213459817 wip 2019-11-18 21:09:21 +02:00
Calin Culianu
f64def2005
wip 2019-11-18 20:56:12 +02:00
Calin Culianu
0466fcf501
wip 2019-11-18 20:48:22 +02:00
Calin Culianu
89aeb474c5
WIP: playing with dling data from bitcoind in Controller class 2019-11-18 20:29:21 +02:00
Calin Culianu
f4091bb005
Devised a scheme for asynch messaging to bitcoind
And added some test code in Controller to use the scheme.

It's very asynchronous.  Needs some tuning long term to see how it deals
with load and perhaps throttle the requests if we know bitcoind is under
load.

But for right now, for testing, it should work ok.

Also in this commit small nits, plus bugfix to RPC::Message factory
methods (I forgot to populate some instance properties when constructing
the objects).

Additionally, we were registering the qMetaType wrong for RPC::Message
and RPC::Message::Id (this has been fixed).
2019-11-18 14:32:48 +02:00
Calin Culianu
0b6d6f0b70
Initial detection of bitcoinDs going up/down for Controller
Playing with lambdas. Detects when bitcoind goes down. Initial code --
can put hooks in the detection for eg. stopping block processing or
starting it, etc.
2019-11-18 09:47:18 +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
742cee4090
a nit 2019-11-18 00:34:24 +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
43b7e915c4
Got rid of more ShuffleUp stuff, added CLI args 2019-11-07 23:55:13 +02:00
Calin Culianu
01d8d01ccd Added stats HTTP server. Also refactored TcpServer 2019-05-09 02:12:58 +03: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
212eb1169b Implemented onNewBlockHeight
- We check the address unspent cache and do cache upkeep
- Various other nits and corner cases handled in this commit
2019-05-05 12:45:26 +03:00
Calin Culianu
b40dfbeb20 Added 'CallOnObject' facility 2019-05-05 02:49:56 +03:00
Calin Culianu
0da480f3c5 Got Controller and EXMgr to use the TimersByNameMixin
This mixin should be useful as we move forward
2019-05-05 01:03:23 +03:00