Commit Graph

1440 Commits

Author SHA1 Message Date
tomFlowee 30ea4aeb98 api docs 2023-07-20 17:45:37 +02:00
tomFlowee 69562c6767 Finish the method signature, add size. 2023-07-17 21:02:43 +02:00
tomFlowee 9685d484cc Init member var 2023-07-17 21:01:59 +02:00
tomFlowee aecaa14d64 Fix constness. 2023-07-15 22:18:14 +02:00
tomFlowee c8fe78f28e whitespace cleanup 2023-07-15 22:01:30 +02:00
tomFlowee 7c7fc70d7d Split app and lib versioning 2023-07-15 22:01:07 +02:00
tomFlowee 166f646cc3 Fixes in API / docs 2023-07-15 20:01:26 +02:00
tomFlowee b4cb8098f9 Add new exported class StringUtils
This uses old methods from the ugly utilstrencodings files
and cleans them up to allow us to install this header file and
use these methods outside of theHub repo.
2023-07-15 12:27:44 +02:00
tomFlowee 33d1bc27f4 Work slowly to fix the disease of unsigned char
There factually is no difference between char and unsigned char
except in very rare cases (like bitshifting). But in APIs they
are incompatible, which is a pain...
2023-07-15 12:24:40 +02:00
tomFlowee 30ac78807c API / docs updates 2023-07-15 11:36:19 +02:00
tomFlowee ebaccb6fee Move include to cpp file 2023-07-15 11:36:19 +02:00
tomFlowee 10510fcb99 Add ProtoBuilder / ProtoParser classes
Protocol Buffers interaction is just another serialization standard,
while its widespread it has fortunately mostly been kept out of
anything relevant or important. Mostly due to the fact that is
really quite bad from a technical perspective.

This adds simple and basic support for creating and parsing
protocol buffer messages, mostly to allow interoperability.
If you want quality: use the MessagBuilder/MessageParser ones instead.
2023-07-14 11:45:47 +02:00
tomFlowee 1e3a4aeee3 Add out of bounds check for MessageParser 2023-07-09 17:09:07 +02:00
tomFlowee f8e9b45229 Be more vigilant in getting peers.
This changes the SPV action to not actually exit when sync
is completed, but instead keep running in the background
so it will detect when a wallet loses a peer and reinstate one.
2023-06-15 14:30:29 +02:00
tomFlowee 0548681605 remove no longer needed qrencoded support 2023-06-15 14:30:29 +02:00
tomFlowee 0ae791af1e Make the implementation fit the methodname.
The methodname:
  blockHeightAtTime()
makes the reader think about the actual height of the chain at that
time. Returning that value until the timestamp of the next block is
reached.
Now the method actally returns that number.

The code does not do any work to account for blocks going backwards in
time compared to the block before.
2023-06-14 16:51:23 +02:00
tomFlowee 148720afa5 Remove outdated comment. 2023-06-14 16:47:39 +02:00
tomFlowee 9435c318f2 Clarify usage of punish() method
We removed the default value in order to avoid misusage of the method
and mistaking the amount with the connection-id.

From Peer we now se the faster overload of punish(), avoiding looping
through the peer list.

Also check return-code when needed.
2023-05-08 11:34:47 +02:00
tomFlowee c637e66cb1 Make compile on gcc 13 2023-05-06 23:29:34 +02:00
tomFlowee fe17559b90 Make building easier, skip running gen_context
The secp256k1 imported library would compile a native executable
and run it to create the ecmult_static_context.h file.

This made cross-compiles much harder without much reason as the
output of the executable is always the same. So why not just add
it to git?

This adds a cmake option to compile the gen_context executable,
but the option defaults to OFF.
2023-05-06 20:42:20 +02:00
tomFlowee f6f6c1a6f1 Make logging be consistent 2023-04-24 15:33:13 +02:00
tomFlowee 2a0b874259 Fix returning an invalid address if nothing is found 2023-04-24 15:32:56 +02:00
tomFlowee 707e15874c Lower log level 2023-04-24 13:48:55 +02:00
tomFlowee f50ad44529 Tweaks in the punishment score
The PeerAddressDB keeps a score for each IP/port we have about how
useful that peer is.
This change re-visits the way we use the DB where we now are more fluid
in our approach to scores. We no longer simply forever-ban a peer after
it made a mistake once.

This rewrites the select-a-peer algo to take timing into account,
preferring a peer that we connected to recently while putting a higher
score on a peer that failed a long time ago so if we start running out
of good peers we start on the not-so-great-but-maybe-improved first.

Good behavior is likewise rewarded so a peer can become higher prio
again, but generally a new IP still gets preferred. Again, the balance
is to keep not-so-great options in the running.
2023-04-24 13:48:55 +02:00
tomFlowee 791bd302bc Mobile networks move 2023-04-21 22:06:46 +02:00
tomFlowee fe0115a5bc Fix distance to limits of the headers call
as the max number of headers is 2000, we should avoid asking any peers
for this data before we are close enough to the tip for it to be easy to
verify as correct.
2023-04-19 15:34:19 +02:00
tomFlowee 9d61366ff4 Be slightly more agressive.
Protocol violations should take less time to have effect.
2023-04-19 15:32:21 +02:00
tomFlowee 3c8cabfc9f Fix copy paste error.
The mempool message has no body.
2023-04-19 13:18:14 +02:00
tomFlowee e4d6528428 Fix off by one. 2023-04-18 09:37:17 +02:00
tomFlowee 153f72b5ac Debug output tweaks 2023-04-17 19:25:07 +02:00
tomFlowee a088a7867a Make GetHeaders replies more relevant
Lets avoid just getting empty answers when we are up-to-date.
2023-04-17 19:24:40 +02:00
tomFlowee dbeb0ff32d Wait longer for the 'getaddr'
Peers take a good amount of time to respond, so wait longer before
connecting to a different peer.
We now wait 60 seconds before creating more connections.
2023-04-17 19:22:05 +02:00
tomFlowee 3e2ab7ced7 Don't send notifications of new blocks until we synched 2023-04-17 11:56:50 +02:00
tomFlowee c6302bd7c0 Limit the amount of times we send mempool 2023-04-06 13:32:30 +02:00
tomFlowee 2545060a2f Tweaks some (debug level) logging. 2023-04-05 18:03:37 +02:00
tomFlowee 3becd7aa45 Remove unused log sections and code
Decentralized all things!

But, really, don't put the logging sections for external apps in the
library code.
2023-04-04 15:47:25 +02:00
tomFlowee 508a03139e Simplify the API
This removes a premature optimization where we avoid hashing the header
in the small case that the interface doesn't actually find any useful
transactions in the block.
It hurts others calling this API, though, as they suddenly need access
to the full header instead of just the blockId.
2023-04-04 13:38:51 +02:00
tomFlowee 91d6328eca Fix possibley sync issues. 2023-04-01 22:59:34 +02:00
tomFlowee 5517bb1c8b Add comment. 2023-04-01 22:58:41 +02:00
tomFlowee 805c2d9893 Split out the too-big logging section 'p2pnet'.
This introduces the spv-sync debug section as a child of the p2p lib
logging section.
2023-04-01 22:58:11 +02:00
tomFlowee 764a022b55 Swap debug output for more logical reading. 2023-04-01 22:54:43 +02:00
tomFlowee bff0b1df21 Fix in restart location.
Make sure we continue to the tip as fast as possible (no duplicates) on
sleep or otherwise losing a peer.
2023-04-01 22:54:43 +02:00
tomFlowee 1d309cd7ae P2PNet: re-do SVP's bloom filter and mempool.
Every peer that we connect to should get the bloom filter set and it
should also get the 'mempool' call sent once which will make that peer
respond with all matches of the bloom filters which are in the mempool.

The tricky part is that we should have the latest bloom filter set on
each of those peers before the mempool is sent, since they work
together.
Also if we are behind, the mempool should not be sent. (It can cause
problems in the wallet if we receive unconfirmed transactions before
mined transactions)

So, when a peer starts downloading merkle blocks, the bloom filter of all
the other peers becomes invalid the moment a match is found by an actual
wallet.
This is Ok on one peer because the merkleblock automatically updates the
filter on match on the server side, but obviously not on the other peers
we have for that wallet.

The approach we follow is that as soon as a sync-run is done on a single
peer (we do a main and also a backup sync), we tell the wallet to re-
build its bloom filter for _all_ peers and if the sync that peer did
leads us to be at the chain-tip, we also send each peer the mempool
command.
2023-04-01 22:54:35 +02:00
tomFlowee 2c0e0bad75 Update SyncChainAction to present day concepts
When the SyncChainAction was written, various interactions we do
today in the ConnectionManager did not happen yet. Features in
Peer didn't exist yet.

This updates the SyncChainAction to take those items into account
and be more responsive and conclue we are 'up to date' faster,
while also leaving behind a better state.
2023-03-27 15:20:50 +02:00
tomFlowee aa6f0676a3 Docs improvements. Mostly API docs 2023-03-27 15:19:05 +02:00
tomFlowee 2322456465 Add thread-safety for the deque too.
A list of weak-pointers itself is not directly thread-safe, the list
itself needs to be synched too.
2023-03-27 15:17:56 +02:00
tomFlowee 5374a50712 Minor cleanups. 2023-03-27 15:16:54 +02:00
tomFlowee 79ea54183e fixes in comments. 2023-03-25 17:26:24 +01:00
tomFlowee 038e7bc0a5 Add new CMake option 'build_apps'.
To enable this means the buildsystem will build all the applications
as well as the libraries.
Applications are 'hub' / 'txVulcano' / 'indexer' etc.
Default this one is turned off.
2023-03-20 19:50:32 +01:00
tomFlowee 6002803fa4 Add more bannable messages.
Alert:
This has been sunset so long ago, no complient BCH client will (/can) use it.

Protoconf:
This looks like its a BSV message.
2023-02-25 19:38:06 +01:00