Commit Graph

632 Commits

Author SHA1 Message Date
TomZ 5ca03cddd5 Futher improve how often save is called
Realize that the changes made before committing are changes I'm
not allowed to save yet and as such move scheduling to the commit()
method.
2019-06-15 21:36:52 +02:00
TomZ d5750426f4 Avoid sending too much 2019-06-15 19:57:35 +02:00
TomZ 1c27a291d0 Add a way for GetTransaction to only return certain outputs 2019-06-15 16:19:27 +02:00
TomZ 2b8e71a2ee Replace some left over BTC instances with BCH 2019-06-15 16:19:27 +02:00
TomZ 0a6146cde2 Reverse sign 2019-06-13 21:47:23 +02:00
TomZ e022e182c7 remove dead seeds and add ABC seed 2019-06-13 21:35:46 +02:00
TomZ fca434b1a6 Make Indexer connect to Hub after loading the conf
Doing it before could lead to incoming data being
processed before the SQL database connection was setup.
2019-06-13 17:12:28 +02:00
TomZ 0bde548548 Improve allocation behavior in BufferPool
The old algorithm could end up doubling the size every time it
ran out, which eventually consumes all memory.
This way we reset to the user-default size when useful and increase
only based on need.

This means that the programmer needs to make a better estimation on
maximum size of messages, but it avoids behavior similar to memory
leaks.
2019-06-13 13:14:26 +02:00
TomZ 2eba51c5c6 Check message size in debug builds.
Double check our message-calculation is proper by checking the result.
Notice that asserts and logDebug both are turned off in release builds,
so this is just added to debug builds.
2019-06-13 12:30:20 +02:00
TomZ e5233fba32 On close, reset the chunked internal data. 2019-06-13 12:21:38 +02:00
TomZ 9f78e93879 Fix recusive calls
Without a recusive mutex recursive calls are not a fun idea.
2019-06-13 00:39:36 +02:00
TomZ 230611b98e Tweak the numbers to be better on IBD 2019-06-12 23:53:24 +02:00
TomZ 10efdada98 whitespace 2019-06-12 21:02:56 +02:00
TomZ 412f8b2ecf Fix possible corruption on reorgs 2019-06-12 21:02:56 +02:00
TomZ 4b96a30279 Use the chain, not the header for the API 2019-06-11 21:15:23 +02:00
TomZ 840cd5a913 Fix change-counting and saving in UTXO
Fix a bug that could make the wait between saves too long and now aim to
make the saving more often because this helps us determine in time that
the file is full so we don't go over the end.
2019-06-11 18:59:51 +02:00
TomZ 3fcd3536ed Clarify coinbase pos in block.
The first field after the header is the number of transactions. This
is a variable-width field of between 1 and 9 bytes.
Coinbase starts after that.
2019-06-11 17:38:30 +02:00
TomZ a310a529ce API cleanup; don't send prevtxhash for coinbases
The prevTxHash and prevOutIndex are irrelevant for coinbases as
the input isn't really an input.
2019-06-11 17:38:30 +02:00
TomZ 9e69a3fef9 Add new indexer; spentoutput
where the UTXO allows you to find an output based on txid+output, the
spentoutput DB turns that around and allows you to find an input that
spends a certain output.

This also fits perfectly find into the UTXO database class, so this
creates a new dir "spent" which is filled as expected.
2019-06-11 17:38:30 +02:00
TomZ 8e7e3b24ae Merge branch 'master' into httpengine 2019-06-10 21:27:46 +02:00
TomZ f9b01e2040 Fixlet in API docs 2019-06-10 21:02:15 +02:00
TomZ 2822b4ed4a Make API handling more robust. 2019-06-10 21:02:15 +02:00
TomZ 0a916c21e9 Add UTXO support to APIs
Generically this looks like this;

IsUnspent
[
  { "txid": "0x111111", "output": 1 },
  { "txid": "0x111111", "output": 11 }
]
IsUnspentReply
[
  { "blockHeight": 1111, "offsetInBlock": 1111, "unspent": true },
  { "unspent": false }
]

GetUnspentOutput
[
  { "txid": "0x111111", "output": 1 },
  { "txid": "0x111111", "output": 0 }
]
GetUnspentOutputReply
[
  { "blockHeight": 1111, "offsetInBlock": 1111, "unspent": true,
    "amount": 1111, "outputscript": "bytearray" },
  { "unspent": false }
]

note: txids are naturally always sha256s.
2019-06-10 21:02:15 +02:00
TomZ ae6fb56654 Merge branch 'master' into httpengine 2019-06-07 09:57:11 +02:00
TomZ e168e3904d Respond to error. 2019-06-07 09:53:05 +02:00
TomZ 99e7f8656c Make headers go to nice subdirs 2019-06-07 09:53:05 +02:00
TomZ b327821236 make compile 2019-06-07 09:53:05 +02:00
TomZ 449f91f46d Move solver method to utils lib
The code that detects standard script-types is now available as a
library function, renamed to live in a namespace;
Script::solver()
2019-06-06 22:21:46 +02:00
TomZ a7f4e942f9 Add README for indexer 2019-06-06 20:15:01 +02:00
TomZ ec2610139e Allow setting indexer connections in conf file
This adds the ability to read from the config file the network
connections. Both the listening address and port as well as the upstream
'hub' address.
2019-06-06 19:44:16 +02:00
TomZ 01641773e1 Import httpengine library
This C++ library is a small framework which creates a full
http(s) server.

This is imported code from the qhttpengine open source project.
I modified some core components in order to make this framework
multi-threading and changed some APIs for cleanlyness. As such
it is not source compatible and getting it accepted upstream is
not realistic.
2019-06-04 21:41:26 +02:00
TomZ 6643059f2a Forgot to add copyright headers to these files 2019-06-04 21:40:12 +02:00
TomZ 0c9f415eb8 Several NetworkManager fixes
This adds all the header ints to chunked messages, solving the problem
of losing RequestId on roundtrips if the answer was too big.

Added a unit test for this "new" features.

This makes callbacks all use shared_from_this() in order to avoid
callbacks being done on deleted instances (thanks boost!).

Last, special case when the user doesn't connect but just sends messages
which caused a send of data, only to realize the connection wasn't open,
and then a connect.
This makes sure we immediately start a connect on queue of a message.
2019-06-04 21:40:02 +02:00
TomZ 57b0b58aa7 Add code to stream a NetworkEndPoint to Logger. 2019-06-03 21:41:04 +02:00
TomZ d10e50803c Avoid warnings from Qt.
Lets not ask about m_verbose when we didn't add it to the parser at all.
2019-06-03 21:39:37 +02:00
TomZ d0662d6e22 Install more headers. 2019-06-03 21:37:30 +02:00
TomZ ca2d6b041a fix connection() not finding an existing connection 2019-06-03 14:37:08 +02:00
TomZ a00938a118 Fix race condition in shutdown of NetworkConnection 2019-06-03 14:37:08 +02:00
TomZ 50870520df Fix NetworkConnection::isConnected() behaviour
This brings it closer to what we expect.
2019-06-03 14:36:59 +02:00
TomZ 08ca3c59c9 Set sane default log levels 2019-06-03 10:59:33 +02:00
TomZ a1dfd1cde9 Work on installable headers 2019-06-03 10:59:33 +02:00
TomZ b6faee185b signal reparseConfig on FloweeServiceApplication
When a user sends a signal SIGHUP, we parse the configs again
traditionally on Unix.
We already use this for log-configs.
This signal allows apps to get notification and reload their
own configs.
2019-06-03 10:59:33 +02:00
TomZ 7203a058a3 Change API call SplitHostPort slightly
Instead of taking an int for the port, take a short.
This matches better with the networkmanager EndPoint struct.
2019-06-02 20:16:49 +02:00
TomZ f868a8274e Make all protocol upgrades equal.
The "UAHF" one used to be "more equal", mostly just because it happened
to be the first.
This makes them all equally equal.

Specifically this removes the special casing and the enum for the 201708
HF (aka BCH fork-point).
We select the right branch now purely based on the historical check-
points.
2019-06-02 13:57:47 +02:00
TomZ db9eb1adfb Install some more files 2019-05-30 13:36:57 +02:00
TomZ e6a23d5f4f Merge branch '2019.05' 2019-05-27 09:28:25 +02:00
TomZ 702addadbb Remove race-conditions in connecting 2019-05-27 09:27:26 +02:00
TomZ 517d0b796d Fix determination of manual reorg
The "Greater than 6 blocks" can be off when we are doing IBD where
headers and chain are not pointing to the same block. Make sure this
works for such an occasion as well.
2019-05-27 09:27:19 +02:00
TomZ 2acde0f30a Allow no progress in download for 6 seconds instead of 2
before disconnecting.

As this only applies to IBD, we can take into account that we have a
higher number of connections typically and this helps stability.
2019-05-27 09:27:14 +02:00
TomZ 01459ec961 Refactor; move lastCommonAncestor to Blocks::Index ns
Out of the main.cpp and usable for a bigger audience.
2019-05-27 09:27:08 +02:00