lnrpc: add timestamp_ns field to ForwardingEvent msg

This allows to use FowardingHistory rpc method to receive the data exactly
as it's stored in lnd and to synchronize incrementally the history to an
external database.
This commit is contained in:
Yaacov Akiba Slama authored and Olaoluwa Osuntokun committed 2021-03-05 16:26:28 -08:00
1 parent 3c14e3d71d
commit 4bab68a808
4 files changed
+817 -795

No files matched your search

+795 -783
View File
File diff suppressed because it is too large. Load diff
+6 -2
View File
@@ -3427,8 +3427,8 @@ message ForwardingHistoryRequest {
}
message ForwardingEvent {
// Timestamp is the time (unix epoch offset) that this circuit was
// completed.
uint64 timestamp = 1;
// completed. Deprecated by timestamp_ns.
uint64 timestamp = 1 [deprecated = true];
// The incoming channel ID that carried the HTLC that created the circuit.
uint64 chan_id_in = 2 [jstype = JS_STRING];
@@ -3459,6 +3459,10 @@ message ForwardingEvent {
// the second half of the circuit.
uint64 amt_out_msat = 10;
// The number of nanoseconds elapsed since January 1, 1970 UTC when this
// circuit was completed.
uint64 timestamp_ns = 11;
// TODO(roasbeef): add settlement latency?
// * use FPE on the chan id?
// * also list failures?
+6 -1
View File
@@ -3557,7 +3557,7 @@
"timestamp": {
"type": "string",
"format": "uint64",
"description": "Timestamp is the time (unix epoch offset) that this circuit was\ncompleted."
"description": "Timestamp is the time (unix epoch offset) that this circuit was\ncompleted. Deprecated by timestamp_ns."
},
"chan_id_in": {
"type": "string",
@@ -3598,6 +3598,11 @@
"type": "string",
"format": "uint64",
"description": "The total amount (in milli-satoshis) of the outgoing HTLC that created\nthe second half of the circuit."
},
"timestamp_ns": {
"type": "string",
"format": "uint64",
"description": "The number of nanoseconds elapsed since January 1, 1970 UTC when this\ncircuit was completed."
}
}
},
+10 -9
View File
@@ -6139,15 +6139,16 @@ func (r *rpcServer) ForwardingHistory(ctx context.Context,
feeMsat := event.AmtIn - event.AmtOut
resp.ForwardingEvents[i] = &lnrpc.ForwardingEvent{
Timestamp: uint64(event.Timestamp.Unix()),
ChanIdIn: event.IncomingChanID.ToUint64(),
ChanIdOut: event.OutgoingChanID.ToUint64(),
AmtIn: uint64(amtInMsat.ToSatoshis()),
AmtOut: uint64(amtOutMsat.ToSatoshis()),
Fee: uint64(feeMsat.ToSatoshis()),
FeeMsat: uint64(feeMsat),
AmtInMsat: uint64(amtInMsat),
AmtOutMsat: uint64(amtOutMsat),
Timestamp: uint64(event.Timestamp.Unix()),
TimestampNs: uint64(event.Timestamp.UnixNano()),
ChanIdIn: event.IncomingChanID.ToUint64(),
ChanIdOut: event.OutgoingChanID.ToUint64(),
AmtIn: uint64(amtInMsat.ToSatoshis()),
AmtOut: uint64(amtOutMsat.ToSatoshis()),
Fee: uint64(feeMsat.ToSatoshis()),
FeeMsat: uint64(feeMsat),
AmtInMsat: uint64(amtInMsat),
AmtOutMsat: uint64(amtOutMsat),
}
}