Commit Graph

1422 Commits

Author SHA1 Message Date
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
TomZ 8ed6d6a3e2 NWM: Fix reconnecting a dead connection
A disconnect would cause the socket to close which caused a
callback which triggered a timer to reconnect after half a minute...

This makes sure that after we manually disconnect we honor that.
2019-05-27 09:23:05 +02:00
TomZ a20118c5fb Add LiveService unit test
The bugreport claimed that sending an existing coinbase would give
inconsistent results. This test can't find any unexpected behaviour.
2019-05-27 09:23:05 +02:00
TomZ 18035c2e66 Start new testing setup for API testing
This is a blackbox type testing for specific API calls.
2019-05-25 17:06:23 +02:00
TomZ 38b4e8b189 Allow hubs -apibind to use 'localhost' string
The command really only accepts IP addresses, but we use 'localhost' as
an exception to bind to loopback for ipv4 and ipv6 at the same time.

Also improve logging of errors and avoid failing to start the API
service if a bind address wasn't an IP.
2019-05-24 23:14:15 +02:00
TomZ 26fda112a0 Fix bug in API for where the answer is a plain bytearray.
This allows RPC wrapper classes to reuse the default implementation also
when the answer is not a uint256
2019-05-23 12:12:25 +02:00
TomZ 59c41123c1 Fix regression, throw when not found. 2019-05-22 23:12:44 +02:00
TomZ a5e8ea401a Sync the new AddressMonitor service API with others
the OffsetInBlock token now has the same value as with other services.
2019-05-18 16:03:26 +02:00
TomZ a54107c168 Make NetworkService thread-safe
This makes the access to the per-peer datastructure lock-free and
thread-safe.
2019-05-18 16:03:22 +02:00
TomZ a1c9e80db0 Make APIs internally consistent.
Where we wrap the old RPC code we need to revert the byte-order from the
strings created there for the uint256.

This simplyfies the code by introducing a helper method.
2019-05-17 20:48:16 +02:00
TomZ 1f52ae7a7f FloweeServiceApplication: support net wildcard
For service applications that bind to networks (currently
only indexer) this allows users to pass the address:
    0.0.0.0
to bind to. The effect will be that we find all the network
interfaces in the system and bind to all of them.
Notice that we already had "localhost" as an alias to bind to both
v4 and v6 loopback interfaces.

This new feature depends on optional dependency QtNetwork.
2019-05-17 12:32:11 +02:00