Handle core timeout during closed channel scan, using correct config variable
This commit is contained in:
parent
6a52725b63
commit
2a6f48d8c8
@ -315,101 +315,97 @@ class ChannelsApi {
|
|||||||
const policy1: Partial<ILightningApi.RoutingPolicy> = channel.node1_policy || {};
|
const policy1: Partial<ILightningApi.RoutingPolicy> = channel.node1_policy || {};
|
||||||
const policy2: Partial<ILightningApi.RoutingPolicy> = channel.node2_policy || {};
|
const policy2: Partial<ILightningApi.RoutingPolicy> = channel.node2_policy || {};
|
||||||
|
|
||||||
try {
|
const query = `INSERT INTO channels
|
||||||
const query = `INSERT INTO channels
|
(
|
||||||
(
|
id,
|
||||||
id,
|
short_id,
|
||||||
short_id,
|
capacity,
|
||||||
capacity,
|
transaction_id,
|
||||||
transaction_id,
|
transaction_vout,
|
||||||
transaction_vout,
|
updated_at,
|
||||||
updated_at,
|
status,
|
||||||
status,
|
node1_public_key,
|
||||||
node1_public_key,
|
node1_base_fee_mtokens,
|
||||||
node1_base_fee_mtokens,
|
node1_cltv_delta,
|
||||||
node1_cltv_delta,
|
node1_fee_rate,
|
||||||
node1_fee_rate,
|
node1_is_disabled,
|
||||||
node1_is_disabled,
|
node1_max_htlc_mtokens,
|
||||||
node1_max_htlc_mtokens,
|
node1_min_htlc_mtokens,
|
||||||
node1_min_htlc_mtokens,
|
node1_updated_at,
|
||||||
node1_updated_at,
|
node2_public_key,
|
||||||
node2_public_key,
|
node2_base_fee_mtokens,
|
||||||
node2_base_fee_mtokens,
|
node2_cltv_delta,
|
||||||
node2_cltv_delta,
|
node2_fee_rate,
|
||||||
node2_fee_rate,
|
node2_is_disabled,
|
||||||
node2_is_disabled,
|
node2_max_htlc_mtokens,
|
||||||
node2_max_htlc_mtokens,
|
node2_min_htlc_mtokens,
|
||||||
node2_min_htlc_mtokens,
|
node2_updated_at
|
||||||
node2_updated_at
|
)
|
||||||
)
|
VALUES (?, ?, ?, ?, ?, ?, 1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, 1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
ON DUPLICATE KEY UPDATE
|
||||||
ON DUPLICATE KEY UPDATE
|
capacity = ?,
|
||||||
capacity = ?,
|
updated_at = ?,
|
||||||
updated_at = ?,
|
status = 1,
|
||||||
status = 1,
|
node1_public_key = ?,
|
||||||
node1_public_key = ?,
|
node1_base_fee_mtokens = ?,
|
||||||
node1_base_fee_mtokens = ?,
|
node1_cltv_delta = ?,
|
||||||
node1_cltv_delta = ?,
|
node1_fee_rate = ?,
|
||||||
node1_fee_rate = ?,
|
node1_is_disabled = ?,
|
||||||
node1_is_disabled = ?,
|
node1_max_htlc_mtokens = ?,
|
||||||
node1_max_htlc_mtokens = ?,
|
node1_min_htlc_mtokens = ?,
|
||||||
node1_min_htlc_mtokens = ?,
|
node1_updated_at = ?,
|
||||||
node1_updated_at = ?,
|
node2_public_key = ?,
|
||||||
node2_public_key = ?,
|
node2_base_fee_mtokens = ?,
|
||||||
node2_base_fee_mtokens = ?,
|
node2_cltv_delta = ?,
|
||||||
node2_cltv_delta = ?,
|
node2_fee_rate = ?,
|
||||||
node2_fee_rate = ?,
|
node2_is_disabled = ?,
|
||||||
node2_is_disabled = ?,
|
node2_max_htlc_mtokens = ?,
|
||||||
node2_max_htlc_mtokens = ?,
|
node2_min_htlc_mtokens = ?,
|
||||||
node2_min_htlc_mtokens = ?,
|
node2_updated_at = ?
|
||||||
node2_updated_at = ?
|
;`;
|
||||||
;`;
|
|
||||||
|
|
||||||
await DB.query(query, [
|
await DB.query(query, [
|
||||||
Common.channelShortIdToIntegerId(channel.channel_id),
|
Common.channelShortIdToIntegerId(channel.channel_id),
|
||||||
Common.channelIntegerIdToShortId(channel.channel_id),
|
Common.channelIntegerIdToShortId(channel.channel_id),
|
||||||
channel.capacity,
|
channel.capacity,
|
||||||
txid,
|
txid,
|
||||||
vout,
|
vout,
|
||||||
Common.utcDateToMysql(channel.last_update),
|
Common.utcDateToMysql(channel.last_update),
|
||||||
channel.node1_pub,
|
channel.node1_pub,
|
||||||
policy1.fee_base_msat,
|
policy1.fee_base_msat,
|
||||||
policy1.time_lock_delta,
|
policy1.time_lock_delta,
|
||||||
policy1.fee_rate_milli_msat,
|
policy1.fee_rate_milli_msat,
|
||||||
policy1.disabled,
|
policy1.disabled,
|
||||||
policy1.max_htlc_msat,
|
policy1.max_htlc_msat,
|
||||||
policy1.min_htlc,
|
policy1.min_htlc,
|
||||||
Common.utcDateToMysql(policy1.last_update),
|
Common.utcDateToMysql(policy1.last_update),
|
||||||
channel.node2_pub,
|
channel.node2_pub,
|
||||||
policy2.fee_base_msat,
|
policy2.fee_base_msat,
|
||||||
policy2.time_lock_delta,
|
policy2.time_lock_delta,
|
||||||
policy2.fee_rate_milli_msat,
|
policy2.fee_rate_milli_msat,
|
||||||
policy2.disabled,
|
policy2.disabled,
|
||||||
policy2.max_htlc_msat,
|
policy2.max_htlc_msat,
|
||||||
policy2.min_htlc,
|
policy2.min_htlc,
|
||||||
Common.utcDateToMysql(policy2.last_update),
|
Common.utcDateToMysql(policy2.last_update),
|
||||||
channel.capacity,
|
channel.capacity,
|
||||||
Common.utcDateToMysql(channel.last_update),
|
Common.utcDateToMysql(channel.last_update),
|
||||||
channel.node1_pub,
|
channel.node1_pub,
|
||||||
policy1.fee_base_msat,
|
policy1.fee_base_msat,
|
||||||
policy1.time_lock_delta,
|
policy1.time_lock_delta,
|
||||||
policy1.fee_rate_milli_msat,
|
policy1.fee_rate_milli_msat,
|
||||||
policy1.disabled,
|
policy1.disabled,
|
||||||
policy1.max_htlc_msat,
|
policy1.max_htlc_msat,
|
||||||
policy1.min_htlc,
|
policy1.min_htlc,
|
||||||
Common.utcDateToMysql(policy1.last_update),
|
Common.utcDateToMysql(policy1.last_update),
|
||||||
channel.node2_pub,
|
channel.node2_pub,
|
||||||
policy2.fee_base_msat,
|
policy2.fee_base_msat,
|
||||||
policy2.time_lock_delta,
|
policy2.time_lock_delta,
|
||||||
policy2.fee_rate_milli_msat,
|
policy2.fee_rate_milli_msat,
|
||||||
policy2.disabled,
|
policy2.disabled,
|
||||||
policy2.max_htlc_msat,
|
policy2.max_htlc_msat,
|
||||||
policy2.min_htlc,
|
policy2.min_htlc,
|
||||||
Common.utcDateToMysql(policy2.last_update)
|
Common.utcDateToMysql(policy2.last_update)
|
||||||
]);
|
]);
|
||||||
} catch (e) {
|
|
||||||
logger.err('$saveChannel() error: ' + (e instanceof Error ? e.message : e));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,7 +49,7 @@ class NetworkSyncService {
|
|||||||
logger.err('$runTasks() error: ' + (e instanceof Error ? e.message : e));
|
logger.err('$runTasks() error: ' + (e instanceof Error ? e.message : e));
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(() => { this.$runTasks(); }, 1000 * config.LIGHTNING.STATS_REFRESH_INTERVAL);
|
setTimeout(() => { this.$runTasks(); }, 1000 * config.LIGHTNING.GRAPH_REFRESH_INTERVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -84,25 +84,29 @@ class NetworkSyncService {
|
|||||||
* Update the `channels` table to reflect the current network graph state
|
* Update the `channels` table to reflect the current network graph state
|
||||||
*/
|
*/
|
||||||
private async $updateChannelsList(channels: ILightningApi.Channel[]): Promise<void> {
|
private async $updateChannelsList(channels: ILightningApi.Channel[]): Promise<void> {
|
||||||
let progress = 0;
|
try {
|
||||||
|
let progress = 0;
|
||||||
|
|
||||||
const graphChannelsIds: string[] = [];
|
const graphChannelsIds: string[] = [];
|
||||||
for (const channel of channels) {
|
for (const channel of channels) {
|
||||||
await channelsApi.$saveChannel(channel);
|
await channelsApi.$saveChannel(channel);
|
||||||
graphChannelsIds.push(channel.channel_id);
|
graphChannelsIds.push(channel.channel_id);
|
||||||
++progress;
|
++progress;
|
||||||
|
|
||||||
const elapsedSeconds = Math.round((new Date().getTime() / 1000) - this.loggerTimer);
|
const elapsedSeconds = Math.round((new Date().getTime() / 1000) - this.loggerTimer);
|
||||||
if (elapsedSeconds > 10) {
|
if (elapsedSeconds > 10) {
|
||||||
logger.info(`Updating channel ${progress}/${channels.length}`);
|
logger.info(`Updating channel ${progress}/${channels.length}`);
|
||||||
this.loggerTimer = new Date().getTime() / 1000;
|
this.loggerTimer = new Date().getTime() / 1000;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.info(`${progress} channels updated`);
|
||||||
|
|
||||||
|
// If a channel if not present in the graph, mark it as inactive
|
||||||
|
channelsApi.$setChannelsInactive(graphChannelsIds);
|
||||||
|
} catch (e) {
|
||||||
|
logger.err(`Cannot update channel list. Reason: ${(e instanceof Error ? e.message : e)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(`${progress} channels updated`);
|
|
||||||
|
|
||||||
// If a channel if not present in the graph, mark it as inactive
|
|
||||||
channelsApi.$setChannelsInactive(graphChannelsIds);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method look up the creation date of the earliest channel of the node
|
// This method look up the creation date of the earliest channel of the node
|
||||||
|
Loading…
x
Reference in New Issue
Block a user