Commit graph

1142 commits

Author SHA1 Message Date
Jason Rhinelander 0706727000 Replace epee::byte_slice with much simpler shared_sv
byte_slice was an abomination that used more than 400 lines of code to
implement what can be implemented in about 20 lines of code with a
std::shared_ptr<std::string> and a std::string_view and a couple
convenience methods.

Much of the levin noise generation using it used it gratuitously: they
always allocate a new string, but then return that wrapped it in a
byte_slice abomination because... well, there's no reason at all except
apparently that the byte_slice author wanted to push byte_slice into
places it didn't belong at all (even if you accept the overbuilt
monstrosity).  Those methods now take a string_view and return a string,
which is what they should have done in the first place.
2020-07-02 12:52:13 -03:00
Jason Rhinelander 5009de02a5 Readline clearing fixes & cowsay replacement
Replaces the silly cow with an ASCII Loki logo:

            .
          oooo
        oooo
      oooo   .           You Loki Wallet has been locked to
    oooo    oooo         protect you while you were away.
      oooo    oooo
        oooo    oooo     (Use `set inactivity-lock-timeout 0`
          oooo    oooo   to disable this inactivity timeout)
            .   oooo
              oooo
            oooo
             .

Also includes a few related miscellaneous updates to how we suspend
input and clear the screen.
2020-07-02 12:52:13 -03:00
Jason Rhinelander cc04770b85 DRY wallet inactivity timer
Replaces the horrible callback wrapper that had to be called from each
and every command callback (and was randomly missing from some) to reset
the inactivity timer with a generic one in the console handler that
allows specifying pre-callback and post-callback commands.
2020-07-02 12:52:13 -03:00
Jason Rhinelander 0de3c64a77 Post-merge: Serialization updates
Updates some old serialization code that crept in with the Monero
upstream merge.
2020-07-02 12:52:13 -03:00
Jason Rhinelander 2be43025c7 Post-merge: std::chrono updates
Replaces reintroduced boost::chronos and posix_times with std::chrono.

Also rewrote the time printing parts of the performance_tests code to do
it better use std::chrono types instead of uint64_ts.
2020-07-02 12:52:13 -03:00
Jason Rhinelander 9ca1056f7f Post-merge updates: epee::is_byte_spannable
Fixes the temporary workarounds added for pre-C++17 is_byte_spannable.
2020-07-02 12:52:13 -03:00
Jason Rhinelander 2357bd6a57 Post-merge updates: std::function
Replaces some boost::functions, and removes some C-style ancient
`std::function<Return(void)>` with C++-style `std::function<Return()>`.

Edit: There's also a map -> unordered_map change hidden in here because
it was in the middle of the other changes and is minor.
2020-07-02 12:52:13 -03:00
Jason Rhinelander 3cc53aa06a Post-merge updates: std::string_view 2020-07-02 12:52:13 -03:00
Jason Rhinelander 778cb89620 Post-merge updates: std::optional 2020-07-02 12:52:13 -03:00
Jason Rhinelander 2a34775543 Post-merge: Remove boost::bind
Removes some more boost::bind's that came in with the upstream merge.
2020-07-02 12:52:13 -03:00
Jason Rhinelander e04d81615c epee/portable_storage: move code to .cpp
There's a bunch of code in inline functions in the header for no good
reason.  Move it to a .cpp.
2020-07-02 12:52:13 -03:00
Jason Rhinelander 95a52c0f25 uuid unordered_map changes
- Use std::unordered_map in epee by giving it a hasher

- Fix the hasher in block_queue to invoke boost's proper hasher.
2020-07-02 12:52:13 -03:00
Jason Rhinelander 86986bd703 Replace boost::bind with lambdas 2020-07-02 12:52:13 -03:00
Jason Rhinelander 718a9496fb Replace boost chrono & posix_time with stl chrono 2020-07-02 12:52:13 -03:00
Jason Rhinelander 515b96e20b Replace (most) boost::thread with std::thread
This removes some boost thread interruption code, but that code is
highly unlikely to have done anything: you cannot preemptively interrupt
a thread, and pretty much anywhere a thread would get stuck is in I/O,
where boost's (voluntary) thread interruption cannot follow.

It also removes thread attributes because they have really limited
usefulness.  There *was* a reason to introduce them many years ago (when
musl libc ran into a stack limit problem with libunbound) but musl
increased the default stack size long since.
2020-07-02 12:52:13 -03:00
Jason Rhinelander 9a9ef745b7 Remove unused call_sys_cmd function 2020-07-02 12:52:13 -03:00
Jason Rhinelander c8e82b44da epee time helper: remove cruft, move to src/
There's a bunch of cruft in here that isn't used anywhere; delete it,
and move the two remaining functions to a .cpp file since this header
gets included almost everywhere.

Also simplify the duration printer to avoid needing boost.
2020-07-02 12:52:13 -03:00
Jason Rhinelander 0c427512f6 Make sure we don't blob serialize padded types
The histogram data, in particular, is not blob serializable: it is a 16
byte struct on most 64-bit architectures, and a 12 byte struct on most
32-bit architectures.
2020-07-02 12:52:13 -03:00
Jason Rhinelander 65a37c65c1 Remove horrible logging macros 2020-07-02 12:52:13 -03:00
Jason Rhinelander d8a29a029b Replace boost::bind's with lambda
Lambdas are often more efficient than boost::bind/std::bind, and pretty
much never less efficient.
2020-07-02 12:52:13 -03:00
Jason Rhinelander d0862eb74b Replace boost internal atomic writes with std::atomic's 2020-07-02 12:52:13 -03:00
Jason Rhinelander 37a341ff6b Remove boost regex dependencies
All boost::regex use is now replaced with std::regex.
2020-07-02 12:52:13 -03:00
Jason Rhinelander 49c693d0a9 Split up common/util.h
common/util.h has become something of a dumping ground of random
functions.  This splits them up a little by moving the filesystem bits
to common/file.h, the sha256sum functions to common/sha256sum.h, and the
(singleton) signal handler to common/signal_handler.h.
2020-07-02 12:52:12 -03:00
Jason Rhinelander 008558ba54 Header updates
Adding/removing a few required/unnneeded headers.
2020-07-02 12:52:12 -03:00
Jason Rhinelander 19ca0e21ee Replace a few boost::bind's with lambda 2020-07-02 12:52:12 -03:00
Jason Rhinelander ae344c2534 epee serialization code: std::variant & C++17 modernization
This overhauls the (unpleasant) epee "portable storage" interface to be
a bit easier to work with.  The diff is fairly large because of the
amount of type indirection that was being used, but at its core does
this simplifications:

- `hsection` was just a typedef for a `section*`, so just use `section*`
instead to not pretend it the value is something it isn't.

- use std::variant instead of boost::variant to store the portable
storage items.

- don't make the variant list recursive with itself since the
serialization doesn't support that anyway (i.e. it doesn't support a
list of lists).

- greatly simplified the variant visiting by using generic lambdas.

- the array traversal interface was a horrible mess.  Replaced it with
a simpler custom iterator approach.

- replaced the `selector<bool>` templated class with templated function.
So for example,

    epee::serialization::selector<is_store>::serialize_t_val_as_blob(...)

becomes:

    epee::serialization::perform_serialize_blob<is_store>(bytes, stg, parent_section, "addr");

and similar for the other types of serializing.
2020-07-02 12:52:12 -03:00
Jason Rhinelander e02545ca4b boost->std: mutex, locks; C++17 lock vars
Changes all boost mutexes, locks, and condition_variables to their stl
equivalents.

Changes all lock_guard/unique_lock/shared_lock to not specify the mutex
type (C++17), e.g.

    std::lock_guard foo{mutex};

instead of

    std::lock_guard<oh::um::what::mutex> foo{mutex};

Also changes some related boost::thread calls to std::thread, and some
related boost chrono calls to stl chrono.

boost::thread isn't changed here to std::thread because some of the
instances rely on some boost thread extensions.
2020-07-02 12:52:12 -03:00
Jason Rhinelander 96354a0e0f boost::optional -> std::optional 2020-07-02 12:52:12 -03:00
Jason Rhinelander 87b147c954 De-analize epee 2020-07-02 12:52:12 -03:00
Jason Rhinelander 6dc5d9ac68 boost::shared_ptr -> std::shared_ptr 2020-07-02 12:52:12 -03:00
Jason Rhinelander b9448febdf Replace boost::string_ref with std::string_view
Also a few related small places in here where a `const std::string&`
made mode sense to be a std::string_view.
2020-07-02 12:52:12 -03:00
Jason Rhinelander 9c5c1dac50 Replace boost::regex with std::regex 2020-07-02 12:52:12 -03:00
Jason Rhinelander e9d48f67f9 Remove stupid OUT macro 2020-07-02 12:52:12 -03:00
Jason Rhinelander 2208432604 Set epee include dir via epee target instead of globally 2020-07-02 12:52:12 -03:00
Jason Rhinelander fb331eefb8 Removed unused epee headers
This is just a pile of dead code that isn't used anywhere.
2020-07-02 12:52:12 -03:00
Jason Rhinelander 83dd656e74 C++17
Switch loki dev branch to C++17 compilation, and update the code with
various C++17 niceties.

- stop including the (deprecated) lokimq/string_view.h header and
instead switch everything to use std::string_view and `""sv` instead of
`""_sv`.

- std::string_view is much nicer than epee::span, so updated various
loki-specific code to use it instead.

- made epee "portable storage" serialization accept a std::string_view
instead of const lvalue std::string so that we can avoid copying.

- switched from mapbox::variant to std::variant

- use `auto [a, b] = whatever()` instead of `T1 a; T2 b; std::tie(a, b)
= whatever()` in a couple places (in the wallet code).

- switch to std::lock(...) instead of boost::lock(...) for simultaneous
lock acquisition.  boost::lock() won't compile in C++17 mode when given
locks of different types.

- removed various pre-C++17 workarounds, e.g. for fold expressions,
unused argument attributes, and byte-spannable object detection.

- class template deduction means lock types no longer have to specify
the mutex, so `std::unique_lock<std::mutex> lock{mutex}` can become
`std::unique_lock lock{mutex}`.  This will make switching any mutex
types (e.g. from boost to std mutexes) far easier as you just have to
update the type in the header and everything should work.  This also
makes the tools::unique_lock and tools::shared_lock methods redundant
(which were a sort of poor-mans-pre-C++17 way to eliminate the
redundancy) so they are now gone and replaced with direct unique_lock or
shared_lock constructions.

- Redid the LNS validation using a string_view; instead of using raw
char pointers the code now uses a string view and chops off parts of the
view as it validates.  So, for instance, it starts with "abcd.loki",
validates the ".loki" and chops the view to "abcd", then validates the
first character and chops to "bcd", validates the last and chops to
"bc", then can just check everything remaining for is-valid-middle-char.

- LNS validation gained a couple minor validation checks in the process:
  - slightly tightened the requirement on lokinet addresses to require
    that the last character of the mapped address is 'y' or 'o' (the
    last base32z char holds only one significant bit).
  - In parse_owner_to_generic_owner made sure that the owner value has
    the correct size (otherwise we could up end not filling or
    overfilling the pubkey buffer).

- Replaced base32z/base64/hex conversions with lokimq's versions which
have a nicer interface, are better optimized, and don't depend on epee.
2020-07-02 12:52:12 -03:00
Jason Rhinelander 7964a27b57 Remove contrib/depends
We've never seriously used it, versions in it tend to bitrot, and it's
redundant with the new cmake-based static builds which are easier to
maintain.
2020-06-16 00:02:14 -03:00
Jason Rhinelander 3b110879b6 Temp fix for boost compatibility
To be reverted with C++17 changes.
2020-06-14 23:43:35 -03:00
Jason Rhinelander 7636155ffc Temporary clang variable template workaround
Temporary in that this will go away (in favour of become `inline`
variables) in the C++17 PR.
2020-06-09 23:06:54 -03:00
Doyle 80c658a48d wallet: Fix wallet call/selecting fields from GET_SERVICE_NODES.
The wallet submits RPC calls for Service Node data by serialising the
data structure. The wallet will _always_ then serialize the fields in
requested_fields_t (to false, by default), so when it reaches the
Daemon, it detects it as if the wallet specifically specified all the
fields as false and returned an empty response breaking staking/registration.
2020-06-05 13:49:15 +10:00
Doyle df07176d14 Revert "Don't couple the cancelling wallet code with console_handler"
This reverts commit c7cf2935a3.
2020-06-03 14:45:51 +10:00
Doyle 67727ab6a7 Merge commit 'ac9f7c9' into MergeUpstream3 2020-05-29 13:47:02 +10:00
Doyle a8abb83b7d Merge commit '2d729fb' into MergeUpstream3 2020-05-28 16:56:01 +10:00
Doyle 54918b37fd Merge commit '323a9e3' into MergeUpstream3 2020-05-28 16:00:50 +10:00
Doyle 05a7d674bd Merge commit '00ede00' into MergeUpstream3 2020-05-28 15:59:14 +10:00
Doyle abb8dfc48e Merge commit 'c4f75fe' into MergeUpstream3 2020-05-28 15:29:00 +10:00
Doyle b71ce522c1 Merge commit '6c7d928' into MergeUpstream3 2020-05-28 15:02:40 +10:00
Doyle 4e8786574e Merge commit '328e9db' into MergeUpstream3 2020-05-28 14:50:12 +10:00
Doyle bda1e6c97b Merge commit '2eee9bcdf8aa33c3fd8cee0685ee16a0131c5b59' into MergeUpstream3 2020-05-28 11:49:14 +10:00
Doyle 7345e62532 Merge commit '092a57df996be75e3a45e9dc69d15138093f503b' into MergeUpstream3 2020-05-28 11:48:41 +10:00