mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-08 00:24:28 +01:00
wallet: Add received_time to htlc_in for forwarding times
We'd like to display the receive and resolution times in the forwardings table. In order to remember the receive time we need to store it in the DB along with the other information. Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
committed by
Rusty Russell
parent
06f090c6a5
commit
2ce9a1e10d
@@ -134,6 +134,8 @@ struct htlc_in *new_htlc_in(const tal_t *ctx,
|
||||
hin->failuremsg = NULL;
|
||||
hin->preimage = NULL;
|
||||
|
||||
hin->received_time = time_now();
|
||||
|
||||
return htlc_in_check(hin, "new_htlc_in");
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "config.h"
|
||||
#include <ccan/htable/htable_type.h>
|
||||
#include <ccan/short_types/short_types.h>
|
||||
#include <ccan/time/time.h>
|
||||
#include <common/amount.h>
|
||||
#include <common/htlc_state.h>
|
||||
#include <common/sphinx.h>
|
||||
@@ -47,6 +48,9 @@ struct htlc_in {
|
||||
/* If they fulfilled, here's the preimage. */
|
||||
struct preimage *preimage;
|
||||
|
||||
/* Remember the timestamp we received this HTLC so we can later record
|
||||
* it, and the resolution time, in the forwards table. */
|
||||
struct timeabs received_time;
|
||||
};
|
||||
|
||||
struct htlc_out {
|
||||
|
||||
@@ -376,6 +376,7 @@ static struct migration dbmigrations[] = {
|
||||
{ "ALTER TABLE channels ADD feerate_base INTEGER;", NULL },
|
||||
{ "ALTER TABLE channels ADD feerate_ppm INTEGER;", NULL },
|
||||
{ NULL, migrate_pr2342_feerate_per_channel },
|
||||
{ "ALTER TABLE channel_htlcs ADD received_time INTEGER", NULL },
|
||||
};
|
||||
|
||||
/* Leak tracking. */
|
||||
|
||||
@@ -1233,8 +1233,9 @@ void wallet_htlc_save_in(struct wallet *wallet,
|
||||
" payment_key,"
|
||||
" hstate,"
|
||||
" shared_secret,"
|
||||
" routing_onion) VALUES "
|
||||
"(?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
|
||||
" routing_onion,"
|
||||
" received_time) VALUES "
|
||||
"(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
|
||||
|
||||
sqlite3_bind_int64(stmt, 1, chan->dbid);
|
||||
sqlite3_bind_int64(stmt, 2, in->key.id);
|
||||
@@ -1258,6 +1259,8 @@ void wallet_htlc_save_in(struct wallet *wallet,
|
||||
sqlite3_bind_blob(stmt, 10, &in->onion_routing_packet,
|
||||
sizeof(in->onion_routing_packet), SQLITE_TRANSIENT);
|
||||
|
||||
sqlite3_bind_timeabs(stmt, 11, in->received_time);
|
||||
|
||||
db_exec_prepared(wallet->db, stmt);
|
||||
in->dbid = sqlite3_last_insert_rowid(wallet->db->sql);
|
||||
}
|
||||
@@ -1351,7 +1354,7 @@ void wallet_htlc_update(struct wallet *wallet, const u64 htlc_dbid,
|
||||
"id, channel_htlc_id, msatoshi, cltv_expiry, hstate, " \
|
||||
"payment_hash, payment_key, routing_onion, " \
|
||||
"failuremsg, malformed_onion," \
|
||||
"origin_htlc, shared_secret"
|
||||
"origin_htlc, shared_secret, received_time"
|
||||
|
||||
static bool wallet_stmt2htlc_in(struct channel *channel,
|
||||
sqlite3_stmt *stmt, struct htlc_in *in)
|
||||
@@ -1393,6 +1396,8 @@ static bool wallet_stmt2htlc_in(struct channel *channel,
|
||||
#endif
|
||||
}
|
||||
|
||||
in->received_time = sqlite3_column_timeabs(stmt, 12);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user