1
1
Fork 0
mirror of https://github.com/oxen-io/lokinet synced 2023-12-14 06:53:00 +01:00
Commit graph

3419 commits

Author SHA1 Message Date
Stephen Shelton
c2c010dbad
Make format 2020-02-25 13:39:28 -07:00
Stephen Shelton
c1b5e453c7
Big I, little i, what begins with I? 2020-02-25 13:39:27 -07:00
Stephen Shelton
1db6c6ae3b
Make format 2020-02-25 13:39:27 -07:00
Stephen Shelton
c2f719c996
Build endpoint paths at even[ish] intervals 2020-02-25 13:39:25 -07:00
Jeff
a8a6c175fc
Merge pull request #1128 from majestrate/use-std-chrono-2020-02-24
make llarp_time_t use std::chrono::milliseconds
2020-02-25 15:36:00 -05:00
Jason Rhinelander
04c618ddae gcc 5 compatibility workaround 2020-02-25 13:33:39 -04:00
Jeff Becker
368acec485
fix last commit 2020-02-25 12:19:40 -05:00
Jeff Becker
b2181f2449
reduce code use 2020-02-25 12:15:14 -05:00
Jeff Becker
fdcd19662f
remove trailing "ms" 2020-02-25 12:07:30 -05:00
Jeff Becker
bf0416cab8
remove Time_t, add operator overload for printing llarp_time_t and add to_json function for serializing llarp_time_t to json 2020-02-25 12:05:13 -05:00
Jeff Becker
ecdab10dac
explictly use std::chrono::milliseconds 2020-02-25 11:05:54 -05:00
Jeff Becker
df427ffa0e
use llarp_time_t instead of auto 2020-02-25 11:02:14 -05:00
Jason Rhinelander
3bd400f6fe Fix string_view C++17 compatibility
string_view was implicitly convertible to std::string, but
std::string_view is only explicitly convertible.  This makes the
`operator std::string` explicit to be more compatible, and re-adds a
bunch of explicit string casts to the code where needed.

(This also fixes the build if changing the standard to c++17)
2020-02-25 11:52:43 -04:00
Jeff Becker
524726e4cc
cast interval to std::chrono::milliseconds before dividing by 4 2020-02-25 10:38:59 -05:00
Jeff Becker
d2d109e92c
llarp_time_t is now using std::chrono 2020-02-24 15:25:03 -05:00
Jeff Becker
f4520ac920
make decaying hashset use llarp::Time_t and move unit tests to use catch2 2020-02-24 15:22:49 -05:00
Jeff Becker
39cdc9e6dd
shift intro on introset update 2020-02-24 15:21:54 -05:00
Jason Rhinelander
f976ebbe49 make format 🤦 2020-02-24 14:38:45 -04:00
Jason Rhinelander
55acec80ec Disable thread annotation when not under libc++
They are fairly useless under stdlibc++ because it doesn't have the
required annotations on stl mutexes and locks, so we just get tons of
useless warnings.
2020-02-24 14:27:44 -04:00
Jason Rhinelander
27025030ce Renamed uint128.h -> uint128.hpp 2020-02-24 14:27:44 -04:00
Jason Rhinelander
3fedd5ba6b Avoid wrong-order initialization on big endian 2020-02-24 14:27:44 -04:00
Jason Rhinelander
2093f94244 Make uint128_t use big/little endian layout internally
Thus if someone wants to memcpy out of it it will have the expected
endianness of the internal data.
2020-02-24 14:27:44 -04:00
Jason Rhinelander
454abb4f9f Avoid copies in mutators
Reimplement operators in terms of mutators, rather than vice versa, so
that mutators don't have to make a copy.
2020-02-24 14:27:44 -04:00
Jason Rhinelander
4207a7cfa3 Rewrite In6ToHUInt to be endian agnostic 2020-02-24 14:27:44 -04:00
Jason Rhinelander
dba3ff7fd3 gcc 5.x string_view workaround 2020-02-24 14:27:44 -04:00
Jason Rhinelander
0839c16f19 Final abseil purge
Bye-bye Google Boost.
2020-02-24 14:27:44 -04:00
Jason Rhinelander
5ce6c01476 Don't use double-underscores
double-underscore names are reserved for the compiler/STL.
2020-02-24 14:27:44 -04:00
Jason Rhinelander
5fcc11f2bf Fix format 2020-02-24 14:27:44 -04:00
Jason Rhinelander
5d1230d7c9 constexpr string_view fixes
Pre-C++17 char_traits::compare isn't constexpr so we can't constexpr the
find/rfind methods that use it.

begin() etc, however, can be constexpr (and need to be for some of the
other constexpr methods here that use them).
2020-02-24 14:27:44 -04:00
Jason Rhinelander
46242ba69b TrimWhiteSpace -> TrimWhitespace
Fix my dumb initial capitalization choice.
2020-02-24 14:27:44 -04:00
Jason Rhinelander
74d4afad51 Remove metric config parsing 2020-02-24 14:27:44 -04:00
Jason Rhinelander
54186c4a89 Replace absl string_view with string_view from lokimq
When we add loki-mq has a dependency we can just alias it, but for now
it's easier to copy the header than add the whole submodule library.
2020-02-24 14:27:44 -04:00
Jason Rhinelander
089056ca5b Remove all ABSL_ATTRIBUTE_UNUSED uses 2020-02-24 14:27:44 -04:00
Jason Rhinelander
5fd830bc36 Prettify uptime duration in log lines
Produces strings such as:

    [+1h09m12.475s]

instead of:

    [+4152475 ms]
2020-02-24 14:27:44 -04:00
Jason Rhinelander
2e9840ea39 Replace abseil date code with Hinnart's date.h
Howard Hinnart's date.h is the library that was accepted as C++20
date/calendar support, so this is essentially a backport of C++20 date
time support.

(It does support timezone support, but requires more of the library and
that seems like overkill for what we need; this just prints UTC
timestamps instead, which need only a header-only include).
2020-02-24 14:27:44 -04:00
Jason Rhinelander
ba1b20153e Miscellaneous small absl removals 2020-02-24 14:27:44 -04:00
Jason Rhinelander
870062e8cc Remove absl optimization
This was being used to get at gcc/clang's __builtin_expect, but we don't
really need that: we can just avoid the check entirely when not in debug
mode which should be even faster.
2020-02-24 14:27:44 -04:00
Jason Rhinelander
5efcd49a3b Deabseil: remove absl::StrCat, de-templatize fromEnv
fromEnv here wasn't usefully templatized (the base template basically
couldn't be used for anything except a string anyway), so just replaced
it with the overloads we need and moved the implementations out of the
header.
2020-02-24 14:27:44 -04:00
Jason Rhinelander
5c95971335 Make C++ literals available everywhere in llarp 2020-02-24 14:27:44 -04:00
Jason Rhinelander
98c34d995b De-abseil: Add our own llarp::TrimWhiteSpace
Adds a TrimWhiteSpace instead of using abseil's.

Adds Catch2 tests for it, and also converts the existing str tests to
catch (which look much, much nicer than the gtest ones).
2020-02-24 14:27:44 -04:00
Jason Rhinelander
00a624ab40 Fix and rename CaselessCmp -> CaselessLessThan
The comparison done here was really weird: by comparing lengths *before*
contents "zz" would sort before "aaa".  It wasn't invalid for the
specific purpose being used here (looking for true/false values), but
would be highly broken if someone tried to use it elsewhere.

Also renamed it because it really is just a `<` implementation, not a
full cmp implementation.
2020-02-24 14:27:44 -04:00
Jason Rhinelander
7d167d3fe4 Add return types to lambda
Without these the return type could be wrong (e.g. supposed to return a
reference but returns a value).
2020-02-22 12:17:53 -04:00
Jason Rhinelander
f84ce61d66 Removed empty cpp files
These aren't needed: CMake already knows how to follow #includes and
rebuild when headers change as long as the headers are included
*somewhere*.  The extra .cpp files here just require building a bunch of
.cpp files with just header content that we just end up throw away
during linking (since the same things will also be compiled in whatever
other compilation units include the same headers).
2020-02-21 23:39:11 -04:00
Jason Rhinelander
fe61367a87 Vastly simplified llarp::util::memFn
There is a huge pile of unnecessary machinery here that can be solved
with a few lambdas and some member function pointer type deduction.
2020-02-21 23:24:33 -04:00
Jason Rhinelander
b4440094b0 De-abseil, part 2: mutex, locks, (most) time
- util::Mutex is now a std::shared_timed_mutex, which is capable of
  exclusive and shared locks.

- util::Lock is still present as a std::lock_guard<util::Mutex>.

- the locking annotations are preserved, but updated to the latest
  supported by clang rather than using abseil's older/deprecated ones.

- ACQUIRE_LOCK macro is gone since we don't pass mutexes by pointer into
  locks anymore (WTF abseil).

- ReleasableLock is gone.  Instead there are now some llarp::util helper
  methods to obtain unique and/or shared locks:
    - `auto lock = util::unique_lock(mutex);` gets an RAII-but-also
      unlockable object (std::unique_lock<T>, with T inferred from
      `mutex`).
    - `auto lock = util::shared_lock(mutex);` gets an RAII shared (i.e.
      "reader") lock of the mutex.
    - `auto lock = util::unique_locks(mutex1, mutex2, mutex3);` can be
      used to atomically lock multiple mutexes at once (returning a
      tuple of the locks).
  This are templated on the mutex which makes them a bit more flexible
  than using a concrete type: they can be used for any type of lockable
  mutex, not only util::Mutex.  (Some of the code here uses them for
  getting locks around a std::mutex).  Until C++17, using the RAII types
  is painfully verbose:

  ```C++
  // pre-C++17 - needing to figure out the mutex type here is annoying:
  std::unique_lock<util::Mutex> lock(mutex);
  // pre-C++17 and even more verbose (but at least the type isn't needed):
  std::unique_lock<decltype(mutex)> lock(mutex);
  // our compromise:
  auto lock = util::unique_lock(mutex);
  // C++17:
  std::unique_lock lock(mutex);
  ```

  All of these functions will also warn (under gcc or clang) if you
  discard the return value.  You can also do fancy things like
  `auto l = util::unique_lock(mutex, std::adopt_lock)` (which lets a
  lock take over an already-locked mutex).

- metrics code is gone, which also removes a big pile of code that was
  only used by metrics:
  - llarp::util::Scheduler
  - llarp:🧵:TimerQueue
  - llarp::util::Stopwatch
2020-02-21 23:22:47 -04:00
Stephen Shelton
ea97a8f2ac
Make format 2020-02-21 10:16:45 -07:00
Stephen Shelton
16be86a5c3
Merge pull request #1116 from tewinget/short-path-names
path builder prints hops, rest print short name
2020-02-21 08:58:05 -08:00
Thomas Winget
fae86281e9 make path short name look nicer 2020-02-20 17:20:17 -05:00
Thomas Winget
145efaf0bb should probably build before committing... 2020-02-20 17:04:08 -05:00
Thomas Winget
74d421ac2d PathBuildNumber -> NextPathBuildNumber because increment side-effect 2020-02-20 16:57:48 -05:00