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

Restore ForwardFeeMonitor's ability to see forwarding fees #223

Merged
merged 3 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
31 changes: 27 additions & 4 deletions Boss/Mod/EarningsTracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,18 +235,41 @@ class EarningsTracker::Impl {
;
)QRY").execute();

uint64_t total_in_earnings = 0;
uint64_t total_in_expenditures = 0;
uint64_t total_out_earnings = 0;
uint64_t total_out_expenditures = 0;

auto out = Json::Out();
auto obj = out.start_object();
for (auto& r : fetch) {
auto in_earnings = r.get<std::uint64_t>(1);
auto in_expenditures = r.get<std::uint64_t>(2);
auto out_earnings = r.get<std::uint64_t>(3);
auto out_expenditures = r.get<std::uint64_t>(4);
auto sub = obj.start_object(r.get<std::string>(0));
sub
.field("in_earnings", r.get<std::uint64_t>(1))
.field("in_expenditures", r.get<std::uint64_t>(2))
.field("out_earnings", r.get<std::uint64_t>(3))
.field("out_expenditures", r.get<std::uint64_t>(4))
.field("in_earnings", in_earnings)
.field("in_expenditures", in_expenditures)
.field("out_earnings", out_earnings)
.field("out_expenditures", out_expenditures)
;
sub.end_object();
total_in_earnings += in_earnings;
total_in_expenditures += in_expenditures;
total_out_earnings += out_earnings;
total_out_expenditures += out_expenditures;
}

auto sub = obj.start_object("total");
sub
.field("in_earnings", total_in_earnings)
.field("in_expenditures", total_in_expenditures)
.field("out_earnings", total_out_earnings)
.field("out_expenditures", total_out_expenditures)
;
sub.end_object();

obj.end_object();

tx.commit();
Expand Down
2 changes: 1 addition & 1 deletion Boss/Mod/ForwardFeeMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void ForwardFeeMonitor::start() {
try {
auto payload = n.params["forward_event"];
if ( !payload.has("out_channel")
|| !payload.has("fee")
|| !payload.has("fee_msat")
|| !payload.has("resolved_time")
|| !payload.has("received_time")
)
Expand Down
21 changes: 21 additions & 0 deletions docs/earnings_tracker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# CLBOSS Earnings Tracker

```mermaid
%%{init: {"flowchart": {"defaultRenderer": "elk"}} }%%

flowchart TB

style EarningsTracker fill:#9fb,stroke:#333,stroke-width:4px
Initiator-->|DbResource|EarningsTracker
ForwardFeeMonitor-->|ForwardFee|EarningsTracker
EarningsRebalancer-->|RequestMoveFunds|EarningsTracker
FundsMover_Runner-->|ResponseMoveFunds|EarningsTracker
EarningsRebalancer-->|RequestEarningsInfo|EarningsTracker
InitialRebalancer-->|RequestEarningsInfo|EarningsTracker
JitRebalancer-->|RequestEarningsInfo|EarningsTracker
StatusCommand-->|SolicitStatus|EarningsTracker
EarningsTracker-->|ResponseEarningsInfo|EarningsRebalancer
EarningsTracker-->|ResponseEarningsInfo|InitialRebalancer
EarningsTracker-->|ResponseEarningsInfo|JitRebalancer
EarningsTracker-->|ProvideStatus|StatusCommand
```
1 change: 0 additions & 1 deletion tests/boss/test_forwardfeemonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ int main() {
"in_msat": "100001001msat",
"out_msatoshi": 100000000,
"out_msat": "100000000msat",
"fee": 1001,
"fee_msat": "1001msat",
"status": "settled",
"received_time": 1560696342.368,
Expand Down
Loading