graph/db: thread context through to HighestChanID

This commit is contained in:
Elle Mouton committed 2025-06-19 14:49:32 +02:00
1 parent 004440a86c
commit 9597f01ce3
7 files changed
+21 -14

No files matched your search

+3 -3
View File
@@ -1881,7 +1881,7 @@ func TestHighestChanID(t *testing.T) {
// If we don't yet have any channels in the database, then we should
// get a channel ID of zero if we ask for the highest channel ID.
bestID, err := graph.HighestChanID()
bestID, err := graph.HighestChanID(ctx)
require.NoError(t, err, "unable to get highest ID")
if bestID != 0 {
t.Fatalf("best ID w/ no chan should be zero, is instead: %v",
@@ -1907,7 +1907,7 @@ func TestHighestChanID(t *testing.T) {
// Now that the edges has been inserted, we'll query for the highest
// known channel ID in the database.
bestID, err = graph.HighestChanID()
bestID, err = graph.HighestChanID(ctx)
require.NoError(t, err, "unable to get highest ID")
if bestID != chanID2.ToUint64() {
@@ -1921,7 +1921,7 @@ func TestHighestChanID(t *testing.T) {
if err := graph.AddChannelEdge(ctx, &edge3); err != nil {
t.Fatalf("unable to create channel edge: %v", err)
}
bestID, err = graph.HighestChanID()
bestID, err = graph.HighestChanID(ctx)
require.NoError(t, err, "unable to get highest ID")
if bestID != chanID3.ToUint64() {
+1 -1
View File
@@ -227,7 +227,7 @@ type V1Store interface { //nolint:interfacebloat
// graph. This represents the "newest" channel from the PoV of the
// chain. This method can be used by peers to quickly determine if
// they're graphs are in sync.
HighestChanID() (uint64, error)
HighestChanID(ctx context.Context) (uint64, error)
// ChanUpdatesInHorizon returns all the known channel edges which have
// at least one edge that has an update timestamp within the specified
+1 -1
View File
@@ -1948,7 +1948,7 @@ func getChanID(tx kvdb.RTx, chanPoint *wire.OutPoint) (uint64, error) {
// HighestChanID returns the "highest" known channel ID in the channel graph.
// This represents the "newest" channel from the PoV of the chain. This method
// can be used by peers to quickly determine if they're graphs are in sync.
func (c *KVStore) HighestChanID() (uint64, error) {
func (c *KVStore) HighestChanID(_ context.Context) (uint64, error) {
var cid uint64
err := kvdb.View(c.db, func(tx kvdb.RTx) error {
+1 -3
View File
@@ -543,9 +543,7 @@ func (s *SQLStore) AddChannelEdge(ctx context.Context,
// can be used by peers to quickly determine if their graphs are in sync.
//
// NOTE: This is part of the V1Store interface.
func (s *SQLStore) HighestChanID() (uint64, error) {
ctx := context.TODO()
func (s *SQLStore) HighestChanID(ctx context.Context) (uint64, error) {
var highestChanID uint64
err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error {
chanID, err := db.HighestSCID(ctx, int16(ProtocolV1))