290 Commits

Author SHA1 Message Date
tomFlowee ccb1016ac7 Avoid deep-copying a bloomfilter when possible. 2021-05-27 19:08:46 +02:00
tomFlowee d3f1d7f454 Whitepace and minor fixes. 2021-02-05 17:32:36 +01:00
tomFlowee ceb44cc3b5 Remove dead code. 2021-02-05 17:26:40 +01:00
tomFlowee f026e626a1 Add notifications for the p2pnet lib. 2021-02-05 17:22:52 +01:00
tomFlowee 70f363cabb Also allow downloading of dsproofs. 2021-02-04 18:09:38 +01:00
tomFlowee 44e8717d1e Send a MEMPOOL message on SPV/merkleblock sync. 2021-02-04 17:39:44 +01:00
tomFlowee 1f2f7c36d2 Port the boost container to the std one.
The unordered_map is now available in stl, and said to be better,
so lets slowly switch over
2021-02-03 16:31:46 +01:00
tomFlowee 1003ad716b Fixlets in log output consistency 2021-02-03 14:41:51 +01:00
tomFlowee 5d6d09e4d6 Assign segments only to good peers
Instead of assigning a privacy segment at connect, wait until we have
determined if this peer is on the same chain as us before we allocate a
peer slot.

This also helps us limit the amount of peers we send our bloom filter to.
2021-02-03 14:41:51 +01:00
tomFlowee 447a2e12e6 Add new action
When a peer never sends headers we now ban it after a timeout based on
the idea that we don't even know if this peer is on the same chain as we
are.
2021-02-03 14:41:51 +01:00
tomFlowee 5baaf984ab Add API docs
also add setInterval()
2021-02-03 14:33:38 +01:00
tomFlowee adfe4081cb Update copyright notice and email address 2021-02-02 13:08:07 +01:00
tomFlowee 3dff9b157d cleanup includes 2021-02-02 13:05:19 +01:00
tomFlowee 7647dde2b5 Handle DNS feeds better.
Avoid issues when the DNS is slow.
Increase the score of an IP that is part of a feed.
2021-01-13 18:15:33 +01:00
tomFlowee c5fca38956 Check basedir or throw
This makes the download manager fail fast, with appropriate logging, on
misconfiguration.
2021-01-13 12:00:15 +01:00
tomFlowee 3fe98afce9 Minor cleanup
This removes some unused includes from common headers and dead code
from some C++ files.
2021-01-05 22:05:25 +01:00
tomFlowee 2f26329eb9 Add some API docs 2021-01-05 21:29:14 +01:00
tomFlowee 8e44b058af Add flags getter 2020-12-17 09:08:34 +01:00
TomZ 93148976e9 add the checkpoint to p2pnet 2020-11-15 15:27:32 +01:00
TomZ 37e1f2fcd3 Fix bad usage of create_directories() 2020-11-14 23:59:01 +01:00
TomZ 2b7ae939cf Simplify the syncchain action. 2020-11-13 21:03:56 +01:00
TomZ 301a4ca3ee Fix properly following the chain-tip
This is done in several steps:

1. Separate my height from the remote peer heights.
Instead of assuming we have one height, recognize that a peer may
not be at the tip at the same time we are. We monitor headers/invs
to update the 'peerHeight' variable.

2. Ask for merkle blocks from a peer to the maximum height of that
peer (but not later than what we validated to be true).
This avoids us asking past the remotes tip which they didn't like.

3. Redo the SyncSPVAction to use all this and make it much more
reliable in finding peers to download from and getting all the
changes as fast as possible.
2020-11-13 21:03:56 +01:00
TomZ 5fa1b50fa1 Remove duplicate 2020-11-13 20:09:29 +01:00
TomZ 370b374431 Avoid uninitialized data 2020-11-12 19:03:35 +01:00
TomZ 0556bc56d1 Fix bugs in SPV sync behavior. 2020-11-09 18:38:38 +01:00
TomZ d2869ef06b Fix bug where we'd ban perfectly good peers
Due to misdetection of stalling the download.
2020-11-07 15:03:27 +01:00
TomZ afd33b2ee0 API docs 2020-11-05 22:06:41 +01:00
TomZ 5e48d0dae7 Be smarter about when to ask for headers.
This avoids us asking a bunch of peers the headers while we are not yet
at the tip.
2020-11-05 21:54:33 +01:00
TomZ 062f62af67 Bugfixes 2020-11-05 21:49:32 +01:00
TomZ e8a2996c84 Persist succesful 'headers' call.
This fixes the issue that a headers call did not get remembered when we
were up-to-date.
2020-11-05 21:48:57 +01:00
TomZ 781805d6a9 Less waiting while finding proper peers 2020-11-05 21:47:54 +01:00
TomZ 9397ab54e6 Accept less peers for non-mainnet chains. 2020-11-05 17:42:51 +01:00
TomZ 599ef31340 Add API docs. 2020-11-05 16:56:14 +01:00
TomZ ae58d68058 Fix loop never increasing. 2020-11-05 16:56:02 +01:00
TomZ 8e2e343695 Fix out-of-range
This makes the fetching of DNS based entries work much better and
actively avoids an off-by-one issue when accessing the vector.
2020-11-05 16:55:38 +01:00
TomZ 376fe9dc86 On startup, start downloading headers
In most cases headers would be automatically downloaded if we didn't
connect to that peer for a while, but that is not a guarentee so lets
make sure we actually start downloading headers from any peer we can :)
2020-10-29 22:18:10 +01:00
TomZ 3f5fe41534 P2PNet: Support multiple chains.
This adds support for the testnet4 chain.
2020-10-29 21:47:53 +01:00
TomZ 027c1a19d4 Don't ban without logline. 2020-10-28 22:06:15 +01:00
TomZ 4b0bcf7bc9 Add priority to privacySegment
We connect to the "first" priority stated segments first, in order to
allow the UX to be made much better since it may take a bit of time to
find peers.
2020-10-19 14:04:57 +02:00
TomZ bf10876914 Add new callback on DataListenerInterface
virtual void setLastSynchedBlockHeight(int height);
2020-10-17 17:25:05 +02:00
TomZ 112ee10f75 Remove stray semicolon 2020-10-17 17:24:45 +02:00
TomZ 84ee1bc3fe Minor: comments and whitespace. 2020-09-17 20:53:56 +02:00
TomZ 652fc1e161 Introduce structure to broadcast transactions.
To send out transactions in the p2p net is quite a lot of work,
you need to find multiple peers to send the transaction to. First
you send an INV, then you respond to a getData to actually send
the transaction and last you wait for 'reject' messages that may
indicate that there is something wrong with the transaction.

This introduces the BroadcastTxData class that wraps a transaction
and gets callbacks for sending and for rejects, abstracting away
all the complexity for the user.
2020-06-08 21:35:10 +02:00
TomZ c2de615c97 Use enum 2020-06-08 21:31:00 +02:00
TomZ cf01da9164 API review: privacySegment
The uint256 and CKeyID classes are the same baseclass with template
differences only, which makes them fragile to use for overloading.

As such rename the convenience overload slightly.
2020-06-07 13:56:55 +02:00
TomZ 2e29bc4f6e When saving to non-existing dir, handle the error. 2020-05-23 14:03:29 +02:00
TomZ 6d9881f413 Play with punishment
Based on the idea that randomly selecting a peer from our database will
prioritize based on the peers punishment score, this sets the punishment
for never connected-to peers at 10 (out of 1000) just to give a minor
benefit to speeding up the meshing.
2020-05-20 20:31:19 +02:00
TomZ 5b63dd4c9b P2PNet: Peer downgrades log-level 2020-05-20 15:20:09 +02:00
TomZ 52f40acb93 Speed up loading 2020-05-19 08:27:53 +02:00
TomZ 7ba11b9880 Unify usage of random number generator. 2020-05-18 19:53:11 +02:00