Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance EarningsTracker with time buckets and primary volume #230

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
b2f5763
Add Util::BacktraceException to capture and display backtraces
ksedgwic Jul 25, 2024
a639a59
Use BacktraceException for appropriate (most) exceptions
ksedgwic Jul 26, 2024
7e4f070
Insert exception what() value in logging messages
ksedgwic Jul 26, 2024
060a3f9
factor parse_json into Jsmn::Object static method
ksedgwic Aug 6, 2024
976f561
add Jsmn::Object::operator==
ksedgwic Aug 6, 2024
337668a
add test_earningstracker for legacy tracking
ksedgwic Aug 6, 2024
6ea7009
add get_now() and mock_get_now() to EarningsTracker and test_earnings…
ksedgwic Aug 6, 2024
b069115
add EarningsTracker::bucket_time quantizer and unit tests
ksedgwic Aug 6, 2024
84f2fae
Upgrade EarningsTracker to time bucket schema, use old semantics
ksedgwic Aug 6, 2024
0ab5ca7
add Either::operator<< to support debugging
ksedgwic Aug 7, 2024
c9c2d3d
add clboss-recent-earnings and clboss-earnings-history
ksedgwic Aug 7, 2024
35cbf0a
f: sort clboss-recent-earnings by earnings sum descending
ksedgwic Aug 11, 2024
dc0f13a
Add associated primary volume (forwarded and rebalanced) to EarningsT…
ksedgwic Aug 15, 2024
2124690
f: fix migration from pre-timebucket to latest, add rollback
ksedgwic Aug 16, 2024
09762dd
f: reorder fields to put relevant adjacent
ksedgwic Aug 16, 2024
01f3eb5
tests: Increase jsmn/test_performance timeout
ksedgwic Aug 16, 2024
99b9f07
Improve commit_hash.h dependencies and generation
ksedgwic Aug 16, 2024
b91d4f5
contrib: add clboss-earnings-history and clboss-recent-earnings scripts
ksedgwic Aug 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Bitcoin/Tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ Tx::Tx(std::string const& s) {
auto is = std::istringstream(std::move(str));
is >> *this;
if (!is.good())
throw std::invalid_argument("Bitcoin::Tx: invalid hex string input.");
throw Util::BacktraceException<std::invalid_argument>("Bitcoin::Tx: invalid hex string input.");
if (is.get() != std::char_traits<char>::eof())
throw std::invalid_argument("Bitcoin::Tx: input string too long.");
throw Util::BacktraceException<std::invalid_argument>("Bitcoin::Tx: input string too long.");
}

Bitcoin::TxId Tx::get_txid() const {
Expand Down
5 changes: 3 additions & 2 deletions Bitcoin/addr_to_scriptPubKey.hpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#ifndef BITCOIN_ADDR_TO_SCRIPTPUBKEY_HPP
#define BITCOIN_ADDR_TO_SCRIPTPUBKEY_HPP

#include"Util/BacktraceException.hpp"
#include<cstdint>
#include<string>
#include<stdexcept>
#include<vector>

namespace Bitcoin {

struct UnknownAddrType : public std::invalid_argument {
struct UnknownAddrType : public Util::BacktraceException<std::invalid_argument> {
public:
UnknownAddrType()
: std::invalid_argument("Bitcoin::UnknownAddrType") { }
: Util::BacktraceException<std::invalid_argument>("Bitcoin::UnknownAddrType") { }
};

/** Bitcoin::addr_to_scriptPubKey
Expand Down
4 changes: 2 additions & 2 deletions Bitcoin/sighash.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ enum SighashFlags
, SIGHASH_ANYONECANPAY = 0x80
};

struct InvalidSighash : public std::invalid_argument {
struct InvalidSighash : public Util::BacktraceException<std::invalid_argument> {
InvalidSighash() =delete;
InvalidSighash(std::string const& msg)
: std::invalid_argument(
: Util::BacktraceException<std::invalid_argument>(
std::string("Bitcoin::InvalidSighash: ") + msg
) { }
};
Expand Down
5 changes: 3 additions & 2 deletions Boltz/ConnectionIF.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef BOLTZ_CONNECTIONIF_HPP
#define BOLTZ_CONNECTIONIF_HPP

#include"Util/BacktraceException.hpp"
#include<memory>
#include<stdexcept>
#include<string>
Expand Down Expand Up @@ -35,10 +36,10 @@ class ConnectionIF {
* @brief thrown when communications with
* the BOLTZ server has problems.
*/
class ApiError : public std::runtime_error {
class ApiError : public Util::BacktraceException<std::runtime_error> {
public:
ApiError(std::string const& e
) : std::runtime_error(e) { }
) : Util::BacktraceException<std::runtime_error>(e) { }
};

}
Expand Down
10 changes: 6 additions & 4 deletions Boss/Mod/ChannelCreateDestroyMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,13 @@ void ChannelCreateDestroyMonitor::start() {
try {
auto payload = params["channel_opened"];
n = Ln::NodeId(std::string(payload["id"]));
} catch (std::runtime_error const&) {
} catch (std::runtime_error const& err) {
return Boss::log( bus, Error
, "ChannelCreateDestroyMonitor: "
"Unexpected channel_opened "
"payload: %s"
"payload: %s: %s"
, Util::stringify(params).c_str()
, err.what()
);
}
/* Is it already in channeled? */
Expand All @@ -174,12 +175,13 @@ void ChannelCreateDestroyMonitor::start() {
n = Ln::NodeId(std::string(payload["peer_id"]));
old_state = std::string(payload["old_state"]);
new_state = std::string(payload["new_state"]);
} catch (std::runtime_error const&) {
} catch (std::runtime_error const& err) {
return Boss::log( bus, Error
, "ChannelCreateDestroyMonitor: "
"Unexpected channel_state_changed "
"payload: %s"
"payload: %s: %s"
, Util::stringify(params).c_str()
, err.what()
);
}
/* Only continue if we are leaving the CHANNELD_NORMAL
Expand Down
5 changes: 3 additions & 2 deletions Boss/Mod/ChannelCreator/Carpenter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,15 @@ Carpenter::construct(std::map<Ln::NodeId, Ln::Amount> plan) {
report << ", ";
report << node;
}
} catch (std::invalid_argument const&) {
} catch (std::invalid_argument const& ex) {
auto os = std::ostringstream();
os << res;
return Boss::log( bus, Error
, "ChannelCreator::Carpenter: "
"Unexpected result from "
"multifundchannel: %s"
"multifundchannel: %s: %s"
, os.str().c_str()
, ex.what()
);
}

Expand Down
5 changes: 3 additions & 2 deletions Boss/Mod/ChannelFinderByEarnedFee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,13 @@ class ChannelFinderByEarnedFee::Impl {
continue;
props.emplace(std::move(dest));
}
} catch (std::exception const&) {
} catch (std::exception const& ex) {
return Boss::log( bus, Error
, "ChannelFinderByEarnedFees: "
"Unexpected result from "
"`listchannels`: %s"
"`listchannels`: %s: %s"
, Util::stringify(res).c_str()
, ex.what()
);
}
res = Jsmn::Object();
Expand Down
5 changes: 3 additions & 2 deletions Boss/Mod/ChannelFinderByListpays.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,13 @@ Ev::Io<void> ChannelFinderByListpays::extract_payees_loop() {
++pit->second;
++count;
return extract_payees_loop();
} catch (std::exception const&) {
} catch (std::exception const& ex) {
return Boss::log( bus, Error
, "ChannelFinderByListpays: "
"Unexpected result from `listpays` "
"`pays` field: %s"
"`pays` field: %s: %s"
, Util::stringify(pay).c_str()
, ex.what()
);
}
});
Expand Down
Loading
Loading