-
Notifications
You must be signed in to change notification settings - Fork 24
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
Fix update recency issue with expanded test coverage #63
Changes from all commits
f525858
6dd0447
0281c0c
0f0a5ef
189dc76
3b570d2
0aff71f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,7 +111,7 @@ impl<L: Deref> GossipPersister<L> where L::Target: Logger { | |
} | ||
|
||
match &gossip_message { | ||
GossipMessage::ChannelAnnouncement(announcement) => { | ||
GossipMessage::ChannelAnnouncement(announcement, _) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why add the override field if we can't use it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I haven't added the unit test for an old announcement yet that was gonna use it. I can do that now to make sure this does end up finding some use immediately. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's alright, I just feel weird adding it freestanding but if you already have code queued up to use it we'll survive. |
||
let scid = announcement.contents.short_channel_id as i64; | ||
|
||
// start with the type prefix, which is already known a priori | ||
|
@@ -127,7 +127,7 @@ impl<L: Deref> GossipPersister<L> where L::Target: Logger { | |
&announcement_signed | ||
])).await.unwrap().unwrap(); | ||
} | ||
GossipMessage::ChannelUpdate(update) => { | ||
GossipMessage::ChannelUpdate(update, seen_override) => { | ||
let scid = update.contents.short_channel_id as i64; | ||
|
||
let timestamp = update.contents.timestamp as i64; | ||
|
@@ -146,10 +146,11 @@ impl<L: Deref> GossipPersister<L> where L::Target: Logger { | |
let mut update_signed = Vec::new(); | ||
update.write(&mut update_signed).unwrap(); | ||
|
||
tokio::time::timeout(POSTGRES_INSERT_TIMEOUT, client | ||
.execute("INSERT INTO channel_updates (\ | ||
let insertion_statement = if cfg!(test) { | ||
"INSERT INTO channel_updates (\ | ||
short_channel_id, \ | ||
timestamp, \ | ||
seen, \ | ||
channel_flags, \ | ||
direction, \ | ||
disable, \ | ||
|
@@ -159,9 +160,32 @@ impl<L: Deref> GossipPersister<L> where L::Target: Logger { | |
fee_proportional_millionths, \ | ||
htlc_maximum_msat, \ | ||
blob_signed \ | ||
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) ON CONFLICT DO NOTHING", &[ | ||
) VALUES ($1, $2, TO_TIMESTAMP($3), $4, $5, $6, $7, $8, $9, $10, $11, $12) ON CONFLICT DO NOTHING" | ||
} else { | ||
"INSERT INTO channel_updates (\ | ||
short_channel_id, \ | ||
timestamp, \ | ||
channel_flags, \ | ||
direction, \ | ||
disable, \ | ||
cltv_expiry_delta, \ | ||
htlc_minimum_msat, \ | ||
fee_base_msat, \ | ||
fee_proportional_millionths, \ | ||
htlc_maximum_msat, \ | ||
blob_signed \ | ||
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) ON CONFLICT DO NOTHING" | ||
}; | ||
|
||
// this may not be used outside test cfg | ||
let _seen_timestamp = seen_override.unwrap_or(timestamp as u32) as f64; | ||
|
||
tokio::time::timeout(POSTGRES_INSERT_TIMEOUT, client | ||
.execute(insertion_statement, &[ | ||
&scid, | ||
×tamp, | ||
#[cfg(test)] | ||
&_seen_timestamp, | ||
&(update.contents.flags as i16), | ||
&direction, | ||
&disable, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you check that this is now unused?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only tested the specific query that I now changed, but prepending short_channel_id ASC does make it no longer use that index.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, my question was if any other queries use that index.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other three channel_update queries don't seem to be using it with my local test database, but my postgres seems to occasionally select indices distinct from yours, so you may wanna double-check your instance, too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mine doesn't seem to either.