Commit Graph

10 Commits

Author SHA1 Message Date
Jason Rhinelander 68c1899cda C++17 changes; replace mapbox with std::variant
Various small C++17 code improvements.

Replace mapbox::variant with std::variant.

Remove the bt_u64 type wrapper; instead we know have `bt_value` which
wraps a variant holding both int64_t and uint64_t, and has contructors
to send signed/unsigned integer types into the appropriate one.
lokimq::get_int checks both as appropriate during extraction.

As a side effect this means we no longer do the uint64_t -> int64_t
conversion on the wire, ever, without needing the wrapper; although this
can break older versions sending large positive integers (i.e. larger
than int64_t max) those weren't actually working completely reliably
with mapbox variant anyway, and the one place using such a value in loki
core (in a checksum) is already fully upgraded across the network
(currently using bt_u64, but always sending a positive value on the
wire).
2020-05-14 20:19:43 -03:00
Jason Rhinelander 1e38f3b1d1 Remove pre-C++17 workarounds/ifdefs 2020-05-12 15:50:36 -03:00
Jason Rhinelander 7b42537801 Require C++17
Removes lokimq::string_view (the type alias is still provided for
backwards compat, but now is always std::string_view).

Bump version (on dev branch) to 1.2.0
2020-05-12 15:33:59 -03:00
Jason Rhinelander 22559548fc Add checking for a negative int in bt_*_consumer 2020-04-30 15:11:45 -03:00
Jason Rhinelander 7b552007df Add bt_u64 wrapper for forcing a uint64_t on the wire
Currently with bt_value if you give a high-bit uint64_t value it encodes
it on the wire as a 2's complement int64_t value (and then converts it
back during deserialization).  This is not a problem for bt_value, but
forces other code to deal with a bt_value convention and makes it
impossible to actually put a high-bit uint64_t value on the wire.

This adds an explicit bt_u64 wrapper to allow doing just that.  This is
only really needed when the type is a 2^64 modulo arithmetic type
(ideally *all* uint64_t's should be that, but in practice there is a ton
of code that misuses unsigned types as "shouldn't be negative" when that
isn't what unsigned means at all. cf C++ Core Guidelines ES.100-102)
2020-04-30 15:11:14 -03:00
Jason Rhinelander 0ce614ef8b Workarounds for old cmake/gcc 2020-03-05 01:33:02 -04:00
Jason Rhinelander e4d371b026 Fixed string_view c++17 compatibility
string_view isn't supposed to be implicitly convertible to std::string
and code would break compiling under c++17 (when our local string_view
is simply a std::string_view typedef).
2020-02-24 22:20:56 -04:00
Jason Rhinelander 7393e8422c Improve on-the-fly bt deserialization interface
This separates the dict traversal into `next_...` functions that return
a key-value pair, and `consume_...` that return just the value.  The
latter is particularly useful when using `skip_until` to position
yourself at a known key.
2020-02-11 02:18:14 -04:00
Jason Rhinelander f75b6cf221 Added batch job implementation + various improvements
This overhauls the proposed batch implementation (described in the
README but previously not implemented) and implements it.

Various other minor improvements and code restructuring.

Added a proposed "request" type to the README to be implemented; this is
like a command, but always expects a ["REPLY", TAG, ...] response.  The
request invoker provides a callback to invoke when such a REPLY arrives.
2020-02-05 20:21:27 -04:00
Jason Rhinelander f3d583c520 Initial LokiMQ release
This library is adapted from lokid's existing quorumnet code (added in
6.x) used for SN-to-SN communication for quorum voting but generalized
to be usable both there and as a basis for other communication channels
with loki projects (for example: wallet-to-lokid communication; loki-ss
and lokinet internal communication with lokid; loki-ss to loki-ss
communication and message passing; perhaps eventually loki p2p traffic).

This initial release compiles but likely has a few warts and bugs that
need ironing out in the implementation before it is production ready.
Some tests will follow.
2020-02-02 22:39:26 -04:00