Commit Graph

1407 Commits

Author SHA1 Message Date
tomFlowee f39953cdc3 Throw properly
off-by-one fix, would not throw when referring to 1 item after the
dataset.
2023-10-16 20:30:42 +02:00
tomFlowee 51e872152b Redo various pieces of logic to be more sane.
A review of the numbers because this easily becomes off-by-one fest
that can make you get lost for hours! :-)
2023-10-16 20:29:14 +02:00
tomFlowee cbeb6dbb0a Allow a static blocks file to start at a checkpoint
The blockchain class can effectively now be shallow,
we can have a list of blockheaders of, for instance, the last year
alone. It builds on top of a known checkpoint (hardcoded block data)
and as long as we do not access block info that is unavailable, things
just work like normal.

We throw at the request of a blockheader that is too old.
2023-10-09 18:08:10 +02:00
tomFlowee 10034d9f0e Add chain-work to checkpoints.
Also rename the member 'checkpoints' to include the m_ prefix to be
internally consistent.
2023-10-09 11:35:20 +02:00
tomFlowee 35df33f3ab Do not allocate items for static block
This changed the vector to no longer have empty entries for the static
chain which were never inserted or read.
2023-10-09 11:35:20 +02:00
tomFlowee 6377a62baf Blockchain database fixes for compression of data. 2023-10-08 12:15:09 +02:00
tomFlowee a65284e0ec Add ConstBuffer clear which makes it invalid. 2023-09-04 14:10:35 +02:00
tomFlowee a2bad4e298 Make bufferpool more sturdy.
Calling commit with a negative value now no longer returns a
valid-but-broken buffer. It now returns an invalid buffer.
2023-09-04 14:10:35 +02:00
tomFlowee 8e2f57ddf7 Implement int32/int64 support for protoparser. 2023-09-02 23:14:18 +02:00
tomFlowee 04877ab4b1 Add new method to convert TO cashaddress
Given an output script, convert to a cash-address.

Notice that this only supports p2pkh / p2sh for now.
2023-09-02 19:40:46 +02:00
tomFlowee 33616fdcec Keep the DB cleaner on peer rejection
Should the peer have been rejected on status or similar, we don't
register a successful connection and avoid the peer from being selected
again since then we don't remove the punishment done on connection
start.
2023-08-17 21:32:09 +02:00
tomFlowee 003cdd6b23 Fix logic; missing braces. 2023-08-17 21:32:09 +02:00
tomFlowee 991eadb311 Add some more debugging output 2023-08-17 21:32:09 +02:00
tomFlowee dba654080e Fix us not getting updates
This fixes the regression that caused a wallet not getting updates after
some time.
2023-08-17 16:58:07 +02:00
tomFlowee 220965ceae Add operator== to EndPoint 2023-08-13 13:59:24 +02:00
tomFlowee f1f148496f Add API docs. 2023-08-02 11:54:05 +02:00
tomFlowee 9f16d67460 Make API more robust
this avoids the endPoint() method sometimes throwing an exception from
std::map::at confusing the caller.
2023-07-20 20:59:26 +02:00
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