Commit Graph

12790 Commits

Author SHA1 Message Date
tomFlowee ffca9b3418 Refactor the BroadcastTxData slightly and pass in the peer. 2024.01.2 2024-01-18 21:46:08 +01:00
tomFlowee 0adb3b5307 Relay of transactions is an essential requirement for us
In practice this won't change anything, but this closes a DOS-like attack
on p2plib using apps where we give slots to peers and then skip using them.
2024-01-18 21:45:11 +01:00
tomFlowee b1749e4c8c Fix peer selection to send tx to. 2024-01-17 19:49:13 +01:00
tomFlowee f1b410dbd0 Fix copy paste error 2024-01-16 10:45:32 +01:00
tomFlowee 18b14a97bc add method to pardon sinners 2024-01-14 17:07:38 +01:00
tomFlowee 542eaa0605 fix logic and be faster to sync.
The intended logic now works which avoids us now finding a download
source faster.
2024-01-14 12:26:01 +01:00
tomFlowee 5fec1b94ef Fix off-by-one in headers check.
A headers call that notifies us about a new block, which is identical to
the one we already have as TIP is now recognized as having the same POW.
2024-01-14 12:16:29 +01:00
tomFlowee e16fb40146 Avoid destructors more for de-registration
This allows us to use a shared pointer while at the same time not having
the problem that a peer de-registration hits an already deleted
PrivacySegment.
2024-01-13 19:26:55 +01:00
tomFlowee 98260e15ac Add API docs. 2024-01-13 18:07:39 +01:00
tomFlowee 874c898430 Remove unused include 2024-01-13 18:06:58 +01:00
tomFlowee ccd53255f8 Avoid doing unneeded work.
When the user-layer triggers a re-connect instead of waiting for the
layer to re-connect then we should avoid doing work twice.
This also avoids a reconnect in some cases.
2024-01-08 16:57:50 +01:00
tomFlowee 64bfb76e06 Linter found issues, we fix 2024-01-08 14:01:21 +01:00
tomFlowee 3f2068b520 New version 2024.01.1 2024-01-07 12:33:34 +01:00
tomFlowee 8d5c1604f8 Add accessors for the ip version support
The AddressDB stores separately the ipv4 and ipv6 addresses, ensuring
that the caller only receives IP addresess compatible with what they
asked.
Until now the booleans to define this were simply private members of the
DB and ipv6 was off.

This exposes those boolean to the outside world.
2024-01-06 22:01:00 +01:00
tomFlowee 618585f22b Add feature; PeerAddressDB statistics generation. 2024-01-06 22:01:00 +01:00
tomFlowee 3b9caf8795 Discard 'lastConnected' from the remote peer.
When a peer sends us an 'addr' message it includes the time they report
they last connected to it. This is untrusted data and we should not act
on it for our our connectivity stats.
2024-01-06 16:45:10 +01:00
tomFlowee 63dd017b4d New version 2024.01.0 2024-01-04 21:54:15 +01:00
tomFlowee 678eccfa70 Be smarter at asking for 'headers' from peers 2024-01-04 21:53:16 +01:00
tomFlowee fb927b9436 Continue shared_ptr convertion of Peer
Last year we started wrapping the Peer object in a shared pointer,
which is used now in the managers.
This continues the idea by making the PrivacySegment use smart
pointers too and the P2PNetInterface is changed to do the same
for downstream applications.
2024-01-04 17:06:32 +01:00
tomFlowee bc47a700a4 Refactor; wrap BufferPool in shared_ptr
As we moved most of the creation of a BufferPool to be via the
Streaming::pool() method, which uses a thread-local, it makes sense
to start cleaning up the design and make it more modern C++.
The above mentioned method would return a reference and you'd see
loads of places use `auto &pool =` which is less than ideal.

As the number of places where we actually instantiate a BufferPool
goes down, the usage of some sort of smart pointer makes more sense.

This now makes all APIs use BufferPool be wrapped in a shared_ptr.
2023-12-21 15:23:23 +01:00
tomFlowee 1905789c9b Use the global instead of a hardcodd value 2023-12-19 23:47:29 +01:00
tomFlowee 1e4dd32ed2 Fix calculation of mmm buffer size 2023-12-19 23:45:43 +01:00
tomFlowee 391019ce49 Import upstream changes for C++20 compatibility
This simply imports the latest version of these support files from
BCHN and implicitly Core.
2023-12-10 13:00:21 +01:00
tomFlowee f596abe6cd Add ConstBuffer support to PrivateKey 2023-12-05 17:12:26 +01:00
tomFlowee 1c53a18048 update version to 2023.11.1 2023.11.1 2023-11-30 19:32:42 +01:00
tomFlowee 9a0cf513b5 Add constbuffer constructor 2023-11-24 22:20:40 +01:00
tomFlowee 2d0aec2cd7 Rename file to match class it is in
This follows the coding style guideline that the file that contains a
class should follow the exact name of this (main) class.

key.{h|cpp} -> PrivateKey.{h|cpp}
2023-11-24 22:20:40 +01:00
tomFlowee fce11e8d4f Rename file to match class it is in.
This follows the coding style guideline that the file that contains a
class should follow the exact name of this (main) class.

pubkey.{h|cpp} -> PublicKey.{h|cpp}
pubkey_utils.{h|cpp} -> PublicKeyUtils.{h|cpp}
2023-11-24 22:20:40 +01:00
tomFlowee afa075ca40 Stop using deprecated call 2023-11-24 22:20:40 +01:00
tomFlowee 8e833c0a63 Add versioning and fix compacting
The system writes a new file every single run (provided new headers were
received) and we sometimes compact them into a big file again.
The code forgot to remove the newly introduced info files of the old
files it compacted. Leaving confusing things happening after.

This solves that by making the first run remove all info files and re-
build them, adding a version byte to allow us freedom to do that in the
future again.
2023.11.0
2023-11-04 15:52:41 +01:00
tomFlowee 1237d8eefd new month, new version 2023-11-03 22:20:55 +01:00
tomFlowee 1c6341ff1d The owner agreed it should be disabled for now.
The bchd seed owner says that since there are no bchd nodes on main-chain
due to the code being outdated, the seed is empty.
We hope this will change in the future, but for now it makes no sense to
query it since it will just generate a fail.
2023-11-03 22:18:30 +01:00
tomFlowee 141553ce6e Improve stale getheaders peer detection
This improves several corner cases on detecting if a peer we
are requesting headers from is actually giving them to us.

Specifically, the height could be zero for a genesis-only view, which
caused the detection to always give the higest score (height zero is
seen as special).

After a node is disconnected we now also reset the history in order to
let the new node get measured from only its own performance.
2023-11-03 22:12:02 +01:00
tomFlowee 4970557f74 Account for a headers message starting with genesis 2023-11-03 22:09:10 +01:00
tomFlowee 8cf80a8634 Cleanup GetHeaders p2p call
Move the builder into the place its used (leftover from earlier ownership change)
Make the message we build be more compatible.
2023-11-03 22:07:57 +01:00
tomFlowee 64b494c97b Simplify the statemachine int. 2023-11-03 18:28:27 +01:00
tomFlowee c8fc2823e7 Port to non-deprecated methods. 2023-11-03 16:59:29 +01:00
tomFlowee 7fdffb919f New versions 2023-11-01 20:33:58 +01:00
tomFlowee 470657fd0e New version 2023.10.0 2023-10-29 11:45:12 +01:00
tomFlowee 1f57aef0df Add comment. 2023-10-24 20:29:31 +02:00
tomFlowee 1b7b24ee9f Fixlets in API docs. Correct arg-name. 2023-10-24 20:24:59 +02:00
tomFlowee 457e8cc78a Remove not written info file
We optimistically create a new info file but as we start we might
instantly realize the file is useless and give up before having written
a single byte.
We now remove that file to avoid stale state.

Also be more verbose on warnings.
2023-10-24 15:13:24 +02:00
tomFlowee b74cb6b029 Pull request 'Add support for Electrum mnemonic phrases.'
Reviewed-on: https://codeberg.org/Flowee/thehub/pulls/5
2023-10-23 14:42:20 +00:00
Calin Culianu 49dab048ab Nit: Default "unknown" mnemonic format to BIP39 2023-10-19 17:02:14 +03:00
Calin Culianu 616ab329e1 Added test vectors for parsing Electrum vs BIP39 to test_apputils.cpp 2023-10-19 16:29:13 +03:00
Calin Culianu 3e05677abf Implemented reviewer suggestion + added unit tests
- Changed API for HDMasterKey::fromMnemonic to use an enum to specify
  BIP39 vs Electrum format phrase
- Added unit test for this class to existing unit tests
2023-10-19 16:13:32 +03:00
Calin Culianu 26c39f58ac Add support for Electrum mnemonic phrases.
These are almost identical to BIP39. They use the same word list except:

- The checksum is calculated differently
- Deriving the master key from them uses a different pbkdf512 salt
  ("electrum" vs "mnemonic")
2023-10-18 20:56:20 +03:00
Tom Zander 89624db80c Merge pull request 'Fix some build issues on macOS + clang' (#4) from cculianu/thehub:fix_build_macos_clang into master
Reviewed-on: https://codeberg.org/Flowee/thehub/pulls/4
2023-10-17 19:15:45 +00:00
Calin Culianu 3945e3069a Fix some build issues on macOS + clang 2023-10-17 22:01:20 +03:00
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