sqldb: use version-specific staleness checks in UpsertChannelPolicy
Update the UpsertChannelPolicy query to apply different staleness checks based on gossip version. For v1 policies, continue checking last_update timestamps. For v2 policies, check block_height instead, using >= comparison to handle policies from the same block. The version-specific WHERE clause ensures that policy updates are only applied when they contain newer information according to the versioning scheme appropriate for that gossip version.
This commit is contained in:
2 files changed
+24
-2
No files matched your search
+12
-1
@@ -3804,7 +3804,18 @@ ON CONFLICT (channel_id, node_id, version)
|
|||||||
signature = EXCLUDED.signature,
|
signature = EXCLUDED.signature,
|
||||||
block_height = EXCLUDED.block_height,
|
block_height = EXCLUDED.block_height,
|
||||||
disable_flags = EXCLUDED.disable_flags
|
disable_flags = EXCLUDED.disable_flags
|
||||||
WHERE EXCLUDED.last_update > graph_channel_policies.last_update
|
WHERE (
|
||||||
|
EXCLUDED.version = 1 AND (
|
||||||
|
graph_channel_policies.last_update IS NULL
|
||||||
|
OR EXCLUDED.last_update > graph_channel_policies.last_update
|
||||||
|
)
|
||||||
|
)
|
||||||
|
OR (
|
||||||
|
EXCLUDED.version = 2 AND (
|
||||||
|
graph_channel_policies.block_height IS NULL
|
||||||
|
OR EXCLUDED.block_height >= graph_channel_policies.block_height
|
||||||
|
)
|
||||||
|
)
|
||||||
RETURNING id
|
RETURNING id
|
||||||
`
|
`
|
||||||
|
|
||||||
|
|||||||
@@ -954,7 +954,18 @@ ON CONFLICT (channel_id, node_id, version)
|
|||||||
signature = EXCLUDED.signature,
|
signature = EXCLUDED.signature,
|
||||||
block_height = EXCLUDED.block_height,
|
block_height = EXCLUDED.block_height,
|
||||||
disable_flags = EXCLUDED.disable_flags
|
disable_flags = EXCLUDED.disable_flags
|
||||||
WHERE EXCLUDED.last_update > graph_channel_policies.last_update
|
WHERE (
|
||||||
|
EXCLUDED.version = 1 AND (
|
||||||
|
graph_channel_policies.last_update IS NULL
|
||||||
|
OR EXCLUDED.last_update > graph_channel_policies.last_update
|
||||||
|
)
|
||||||
|
)
|
||||||
|
OR (
|
||||||
|
EXCLUDED.version = 2 AND (
|
||||||
|
graph_channel_policies.block_height IS NULL
|
||||||
|
OR EXCLUDED.block_height >= graph_channel_policies.block_height
|
||||||
|
)
|
||||||
|
)
|
||||||
RETURNING id;
|
RETURNING id;
|
||||||
|
|
||||||
-- name: GetChannelPolicyByChannelAndNode :one
|
-- name: GetChannelPolicyByChannelAndNode :one
|
||||||
|
|||||||
Reference in new issue
Block a user