88 Commits

Author SHA1 Message Date
tomFlowee 30643a8bcf Improve readability. 2026-05-19 17:44:04 +02:00
John Galt 251107d457 streaming: reject invalid P2P parser byte counts 2026-05-19 10:22:58 +02:00
tomFlowee fdd9274156 Add bytesToHex helper method 2026-03-04 17:58:05 +01:00
tomFlowee c79188242e Add new method to Streaming namespace
Streaming::readCompactSize()

As the reverse was already there, it makes sense to be consisten.
This includes a unit test.
2025-10-28 12:45:26 +01:00
tomFlowee 5b5b595584 Add direct write
This allows the compiler to avoid going via std::string
2025-05-15 16:54:26 +02:00
tomFlowee ad1a186989 Make using bind parser easier from BufferPool 2025-04-19 15:32:58 +02:00
tomFlowee 998a4ed7ff Add uin256 bind 2025-04-15 21:40:33 +02:00
tomFlowee f764f2de78 Add new binding type. 2025-04-12 19:56:03 +02:00
tomFlowee 3c854c1ac9 Add simpler way to get data out of a message 2025-04-12 17:05:01 +02:00
tomFlowee ed93012ba6 Add extra write() helper method. 2025-01-27 20:40:24 +01:00
tomFlowee 4560355458 Introduce a different general log category. 2025-01-13 23:37:51 +01:00
tomFlowee c7192dff41 Add text-limit argument to writeHex
The BufferPool::writeHex() method takes a string-pointer, we add an int
max-number-of-chars to be parsed on that string.
This allows us to not just stop at the first non-hex char, but also
after a set number of characters.

This effectively allows us to use non-zere-terminated strings as
argument too.
2024-10-03 14:07:10 +02:00
tomFlowee 135a43c625 Add implementation for building token txs
This includes a small refactor to move the writeCompactSize method
from P2PBuilder internally to a public namespace in StreamingUtils
2024-09-07 12:13:43 +02:00
tomFlowee 68cf4ae48f Fix ConstBuffer::indexOf constness
This method is now const, as it should be.
2024-06-11 21:34:41 +02:00
tomFlowee 6a84a262cc Add more ConstBuffer helper methods
This adds endsWith() and an extra startsWith() overload.

We also added tests for the case when either the argument or the object
are empty and specify the behavior. I copied the behavior of QString.

See unit tests that specify the behavior with empties.
2024-06-11 17:57:17 +02:00
tomFlowee 8da1892995 Add ConstBuffer toHex() methods to get a string out. 2024-04-21 00:11:47 +02:00
tomFlowee 4fe9d69e7b Use more specific define-guards 2024-01-24 21:03:58 +01:00
tomFlowee 874c898430 Remove unused include 2024-01-13 18:06:58 +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
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
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 30ea4aeb98 api docs 2023-07-20 17:45:37 +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 148720afa5 Remove outdated comment. 2023-06-14 16:47:39 +02:00
tomFlowee c6720314ff API fix 2022-08-13 23:42:40 +02:00
tomFlowee 32c7f28b24 Change cast.
This correctly makes our value signed before turning it into
a negative number.
2022-07-06 14:28:34 +02:00
tomFlowee 26262783de Allow mid(1, 0) to be called
This now creates a zero size, empty, result.
2022-02-10 18:02:50 +01:00
tomFlowee c0989158c0 Add API docs. 2022-02-08 19:03:14 +01:00
tomFlowee 41e00b134f Add convenience methods on ConstBuffer
this adds indexOf() and toString()
2022-01-25 23:59:54 +01:00
tomFlowee 5bebaeb37c Add another write() helper method. 2022-01-24 13:19:23 +01:00
tomFlowee 7376c28a3c Move pool thread-local getter to utils.
This nicely cleans up the calling usage a static on the connection
manager instance.
2022-01-24 12:06:37 +01:00
tomFlowee 7b5c10845e Add helper method 2022-01-21 22:44:36 +01:00
tomFlowee b1f6f497dd Prevent misuse of API 2021-08-05 22:43:24 +02:00
tomFlowee e7a229e806 Add some API docs. 2021-07-01 20:09:04 +02:00
tomFlowee ae78dd0bb8 Update email address 2021-06-20 22:44:44 +02:00
tomFlowee d797b1bf50 Minor additions of helper methods.
Tested in the upcoming unit test.
2021-03-24 21:00:25 +01:00
tomFlowee 9025a2e2ea Add DoubleSpendService to listen to all double spend notifications 2021-03-16 19:53:14 +01:00
tomFlowee 7406cd6ecf Remove dead code (xor of stream). 2021-03-16 19:34:33 +01:00
tomFlowee 235df9c5f0 Add loading of DSProof from a constbuffer. 2021-01-20 21:35:20 +01:00
tomFlowee 2ed836a71d Support buffers for strings too 2021-01-06 23:16:19 +01:00
tomFlowee 407dd2f2ab Simplify messageparser.
Remove some unused methods and complexity.
2021-01-06 19:37:27 +01:00
TomZ a337c6b6b5 Use consistent variable typing.
Use uint8 and friends instead.
2020-10-31 19:51:04 +01:00
TomZ cde4d35d9c API docs 2020-09-18 20:37:43 +02:00
TomZ 1434383f01 Simplify
Lets not be afraid of some pointer math...
2020-09-17 20:55:14 +02:00
TomZ c7aee5efa9 Prevent incorrect usage and double delete
This only applies to the case where the MessageBuilder was used without
an external pool, but lets make sure the code is robust for even that
case.
2020-09-02 13:54:45 +02:00
TomZ 33c6758ea5 Add some API docs. 2020-05-23 14:03:42 +02:00