graph/db: rename V1Store to Store
The underling store will store gossip messages across gossip versions and we will instead expose version parameters on many of the methods. So this interface really just abstracts the underlying store/schema type.
This commit is contained in:
11 files changed
+111
-111
No files matched your search
+44
-44
@@ -163,7 +163,7 @@ type BatchedSQLQueries interface {
|
||||
sqldb.BatchedTx[SQLQueries]
|
||||
}
|
||||
|
||||
// SQLStore is an implementation of the V1Store interface that uses a SQL
|
||||
// SQLStore is an implementation of the Store interface that uses a SQL
|
||||
// database as the backend.
|
||||
type SQLStore struct {
|
||||
cfg *SQLStoreConfig
|
||||
@@ -183,9 +183,9 @@ type SQLStore struct {
|
||||
srcNodeMu sync.Mutex
|
||||
}
|
||||
|
||||
// A compile-time assertion to ensure that SQLStore implements the V1Store
|
||||
// A compile-time assertion to ensure that SQLStore implements the Store
|
||||
// interface.
|
||||
var _ V1Store = (*SQLStore)(nil)
|
||||
var _ Store = (*SQLStore)(nil)
|
||||
|
||||
// SQLStoreConfig holds the configuration for the SQLStore.
|
||||
type SQLStoreConfig struct {
|
||||
@@ -235,7 +235,7 @@ func NewSQLStore(cfg *SQLStoreConfig, db BatchedSQLQueries,
|
||||
// graph. If it is present from before, this will update that node's
|
||||
// information.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) AddNode(ctx context.Context,
|
||||
node *models.Node, opts ...batch.SchedulerOption) error {
|
||||
|
||||
@@ -265,7 +265,7 @@ func (s *SQLStore) AddNode(ctx context.Context,
|
||||
// key. If the node isn't found in the database, then ErrGraphNodeNotFound is
|
||||
// returned.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) FetchNode(ctx context.Context,
|
||||
pubKey route.Vertex) (*models.Node, error) {
|
||||
|
||||
@@ -289,7 +289,7 @@ func (s *SQLStore) FetchNode(ctx context.Context,
|
||||
// with a true boolean. Otherwise, an empty time.Time is returned with a false
|
||||
// boolean.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) HasNode(ctx context.Context,
|
||||
pubKey [33]byte) (time.Time, bool, error) {
|
||||
|
||||
@@ -330,7 +330,7 @@ func (s *SQLStore) HasNode(ctx context.Context,
|
||||
// that the graph DB is aware of. The returned boolean indicates if the
|
||||
// given node is unknown to the graph DB or not.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) AddrsForNode(ctx context.Context,
|
||||
nodePub *btcec.PublicKey) (bool, []net.Addr, error) {
|
||||
|
||||
@@ -372,7 +372,7 @@ func (s *SQLStore) AddrsForNode(ctx context.Context,
|
||||
// DeleteNode starts a new database transaction to remove a vertex/node
|
||||
// from the database according to the node's public key.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) DeleteNode(ctx context.Context,
|
||||
pubKey route.Vertex) error {
|
||||
|
||||
@@ -423,7 +423,7 @@ func (s *SQLStore) FetchNodeFeatures(nodePub route.Vertex) (
|
||||
// A channel is disabled when two of the associated ChanelEdgePolicies
|
||||
// have their disabled bit on.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) DisabledChannelIDs() ([]uint64, error) {
|
||||
var (
|
||||
ctx = context.TODO()
|
||||
@@ -450,7 +450,7 @@ func (s *SQLStore) DisabledChannelIDs() ([]uint64, error) {
|
||||
|
||||
// LookupAlias attempts to return the alias as advertised by the target node.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) LookupAlias(ctx context.Context,
|
||||
pub *btcec.PublicKey) (string, error) {
|
||||
|
||||
@@ -488,7 +488,7 @@ func (s *SQLStore) LookupAlias(ctx context.Context,
|
||||
// a path finding algorithm in order to explore the reachability of another
|
||||
// node based off the source node.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) SourceNode(ctx context.Context) (*models.Node,
|
||||
error) {
|
||||
|
||||
@@ -517,7 +517,7 @@ func (s *SQLStore) SourceNode(ctx context.Context) (*models.Node,
|
||||
// node is to be used as the center of a star-graph within path finding
|
||||
// algorithms.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) SetSourceNode(ctx context.Context,
|
||||
node *models.Node) error {
|
||||
|
||||
@@ -562,7 +562,7 @@ func (s *SQLStore) SetSourceNode(ctx context.Context,
|
||||
// nodes to quickly determine if they have the same set of up to date node
|
||||
// announcements.
|
||||
//
|
||||
// NOTE: This is part of the V1Store interface.
|
||||
// NOTE: This is part of the Store interface.
|
||||
func (s *SQLStore) NodeUpdatesInHorizon(startTime, endTime time.Time,
|
||||
opts ...IteratorOption) iter.Seq2[*models.Node, error] {
|
||||
|
||||
@@ -671,7 +671,7 @@ func (s *SQLStore) NodeUpdatesInHorizon(startTime, endTime time.Time,
|
||||
// supports. The chanPoint and chanID are used to uniquely identify the edge
|
||||
// globally within the database.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) AddChannelEdge(ctx context.Context,
|
||||
edge *models.ChannelEdgeInfo, opts ...batch.SchedulerOption) error {
|
||||
|
||||
@@ -726,7 +726,7 @@ func (s *SQLStore) AddChannelEdge(ctx context.Context,
|
||||
// This represents the "newest" channel from the PoV of the chain. This method
|
||||
// can be used by peers to quickly determine if their graphs are in sync.
|
||||
//
|
||||
// NOTE: This is part of the V1Store interface.
|
||||
// NOTE: This is part of the Store interface.
|
||||
func (s *SQLStore) HighestChanID(ctx context.Context) (uint64, error) {
|
||||
var highestChanID uint64
|
||||
err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error {
|
||||
@@ -757,7 +757,7 @@ func (s *SQLStore) HighestChanID(ctx context.Context) (uint64, error) {
|
||||
// determined by the lexicographical ordering of the identity public keys of the
|
||||
// nodes on either side of the channel.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) UpdateEdgePolicy(ctx context.Context,
|
||||
edge *models.ChannelEdgePolicy,
|
||||
opts ...batch.SchedulerOption) (route.Vertex, route.Vertex, error) {
|
||||
@@ -855,7 +855,7 @@ func (s *SQLStore) updateEdgeCache(e *models.ChannelEdgePolicy,
|
||||
// channel's outpoint, whether we have a policy for the channel and the channel
|
||||
// peer's node information.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) ForEachSourceNodeChannel(ctx context.Context,
|
||||
cb func(chanPoint wire.OutPoint, havePolicy bool,
|
||||
otherNode *models.Node) error, reset func()) error {
|
||||
@@ -914,7 +914,7 @@ func (s *SQLStore) ForEachSourceNodeChannel(ctx context.Context,
|
||||
// returns an error, then the transaction is aborted and the iteration stops
|
||||
// early.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) ForEachNode(ctx context.Context,
|
||||
cb func(node *models.Node) error, reset func()) error {
|
||||
|
||||
@@ -982,7 +982,7 @@ func (s *SQLStore) ForEachNodeCacheable(ctx context.Context,
|
||||
//
|
||||
// Unknown policies are passed into the callback as nil values.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) ForEachNodeChannel(ctx context.Context, nodePub route.Vertex,
|
||||
cb func(*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
|
||||
*models.ChannelEdgePolicy) error, reset func()) error {
|
||||
@@ -1099,7 +1099,7 @@ func (s *SQLStore) updateChanCacheBatch(edgesToCache map[uint64]ChannelEdge) {
|
||||
// 5. Update cache after successful batch
|
||||
// 6. Repeat with updated pagination cursor until no more results
|
||||
//
|
||||
// NOTE: This is part of the V1Store interface.
|
||||
// NOTE: This is part of the Store interface.
|
||||
func (s *SQLStore) ChanUpdatesInHorizon(startTime, endTime time.Time,
|
||||
opts ...IteratorOption) iter.Seq2[ChannelEdge, error] {
|
||||
|
||||
@@ -1268,7 +1268,7 @@ func (s *SQLStore) ChanUpdatesInHorizon(startTime, endTime time.Time,
|
||||
// result in an additional round-trip to the database, so it should only be used
|
||||
// if the addresses are actually needed.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) ForEachNodeCached(ctx context.Context, withAddrs bool,
|
||||
cb func(ctx context.Context, node route.Vertex, addrs []net.Addr,
|
||||
chans map[uint64]*DirectedChannel) error, reset func()) error {
|
||||
@@ -1564,7 +1564,7 @@ func (s *SQLStore) ForEachChannelCacheable(cb func(*models.CachedEdgeInfo,
|
||||
// for that particular channel edge routing policy will be passed into the
|
||||
// callback.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) ForEachChannel(ctx context.Context,
|
||||
cb func(*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
|
||||
*models.ChannelEdgePolicy) error, reset func()) error {
|
||||
@@ -1582,7 +1582,7 @@ func (s *SQLStore) ForEachChannel(ctx context.Context,
|
||||
// timestamp info of the latest received channel update messages of the channel
|
||||
// will be included in the response.
|
||||
//
|
||||
// NOTE: This is part of the V1Store interface.
|
||||
// NOTE: This is part of the Store interface.
|
||||
func (s *SQLStore) FilterChannelRange(startHeight, endHeight uint32,
|
||||
withTimestamps bool) ([]BlockChannelRange, error) {
|
||||
|
||||
@@ -1702,7 +1702,7 @@ func (s *SQLStore) FilterChannelRange(startHeight, endHeight uint32,
|
||||
// zombie. This method is used on an ad-hoc basis, when channels need to be
|
||||
// marked as zombies outside the normal pruning cycle.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) MarkEdgeZombie(chanID uint64,
|
||||
pubKey1, pubKey2 [33]byte) error {
|
||||
|
||||
@@ -1736,7 +1736,7 @@ func (s *SQLStore) MarkEdgeZombie(chanID uint64,
|
||||
|
||||
// MarkEdgeLive clears an edge from our zombie index, deeming it as live.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) MarkEdgeLive(chanID uint64) error {
|
||||
s.cacheMu.Lock()
|
||||
defer s.cacheMu.Unlock()
|
||||
@@ -1787,7 +1787,7 @@ func (s *SQLStore) MarkEdgeLive(chanID uint64) error {
|
||||
// zombie, then the two node public keys corresponding to this edge are also
|
||||
// returned.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) IsZombieEdge(chanID uint64) (bool, [33]byte, [33]byte,
|
||||
error) {
|
||||
|
||||
@@ -1830,7 +1830,7 @@ func (s *SQLStore) IsZombieEdge(chanID uint64) (bool, [33]byte, [33]byte,
|
||||
|
||||
// NumZombies returns the current number of zombie channels in the graph.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) NumZombies() (uint64, error) {
|
||||
var (
|
||||
ctx = context.TODO()
|
||||
@@ -1865,7 +1865,7 @@ func (s *SQLStore) NumZombies() (uint64, error) {
|
||||
// that resurrects the channel from its zombie state. The markZombie bool
|
||||
// denotes whether to mark the channel as a zombie.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) DeleteChannelEdges(strictZombiePruning, markZombie bool,
|
||||
chanIDs ...uint64) ([]*models.ChannelEdgeInfo, error) {
|
||||
|
||||
@@ -1970,7 +1970,7 @@ func (s *SQLStore) DeleteChannelEdges(strictZombiePruning, markZombie bool,
|
||||
// within the database. In this case, the ChannelEdgePolicy's will be nil, and
|
||||
// the ChannelEdgeInfo will only include the public keys of each node.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) FetchChannelEdgesByID(chanID uint64) (
|
||||
*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
|
||||
*models.ChannelEdgePolicy, error) {
|
||||
@@ -2067,7 +2067,7 @@ func (s *SQLStore) FetchChannelEdgesByID(chanID uint64) (
|
||||
// information for the channel itself is returned as well as two structs that
|
||||
// contain the routing policies for the channel in either direction.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) FetchChannelEdgesByOutpoint(op *wire.OutPoint) (
|
||||
*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
|
||||
*models.ChannelEdgePolicy, error) {
|
||||
@@ -2137,7 +2137,7 @@ func (s *SQLStore) FetchChannelEdgesByOutpoint(op *wire.OutPoint) (
|
||||
// it is not found, then the zombie index is checked and its result is returned
|
||||
// as the second boolean.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) HasChannelEdge(chanID uint64) (time.Time, time.Time, bool,
|
||||
bool, error) {
|
||||
|
||||
@@ -2253,7 +2253,7 @@ func (s *SQLStore) HasChannelEdge(chanID uint64) (time.Time, time.Time, bool,
|
||||
// passed channel point (outpoint). If the passed channel doesn't exist within
|
||||
// the database, then ErrEdgeNotFound is returned.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) ChannelID(chanPoint *wire.OutPoint) (uint64, error) {
|
||||
var (
|
||||
ctx = context.TODO()
|
||||
@@ -2288,7 +2288,7 @@ func (s *SQLStore) ChannelID(chanPoint *wire.OutPoint) (uint64, error) {
|
||||
// given public key is seen as a public node in the graph from the graph's
|
||||
// source node's point of view.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) IsPublicNode(pubKey [33]byte) (bool, error) {
|
||||
ctx := context.TODO()
|
||||
|
||||
@@ -2313,7 +2313,7 @@ func (s *SQLStore) IsPublicNode(pubKey [33]byte) (bool, error) {
|
||||
// of the query. This can be used to respond to peer queries that are seeking to
|
||||
// fill in gaps in their view of the channel graph.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) FetchChanInfos(chanIDs []uint64) ([]ChannelEdge, error) {
|
||||
var (
|
||||
ctx = context.TODO()
|
||||
@@ -2407,7 +2407,7 @@ func (s *SQLStore) forEachChanWithPoliciesInSCIDList(ctx context.Context,
|
||||
// channels another peer knows of that we don't. The ChannelUpdateInfos for the
|
||||
// known zombies is also returned.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) FilterKnownChanIDs(chansInfo []ChannelUpdateInfo) ([]uint64,
|
||||
[]ChannelUpdateInfo, error) {
|
||||
|
||||
@@ -2531,7 +2531,7 @@ func (s *SQLStore) forEachChanInSCIDList(ctx context.Context, db SQLQueries,
|
||||
// NOTE: this prunes nodes across protocol versions. It will never prune the
|
||||
// source nodes.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) PruneGraphNodes() ([]route.Vertex, error) {
|
||||
var ctx = context.TODO()
|
||||
|
||||
@@ -2560,7 +2560,7 @@ func (s *SQLStore) PruneGraphNodes() ([]route.Vertex, error) {
|
||||
// the target block along with any pruned nodes are returned if the function
|
||||
// succeeds without error.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) PruneGraph(spentOutputs []*wire.OutPoint,
|
||||
blockHash *chainhash.Hash, blockHeight uint32) (
|
||||
[]*models.ChannelEdgeInfo, []route.Vertex, error) {
|
||||
@@ -2715,7 +2715,7 @@ func (s *SQLStore) deleteChannels(ctx context.Context, db SQLQueries,
|
||||
// returned are the ones that need to be watched on chain to detect channel
|
||||
// closes on the resident blockchain.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) ChannelView() ([]EdgePoint, error) {
|
||||
var (
|
||||
ctx = context.TODO()
|
||||
@@ -2781,7 +2781,7 @@ func (s *SQLStore) ChannelView() ([]EdgePoint, error) {
|
||||
// to tell if the graph is currently in sync with the current best known UTXO
|
||||
// state.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) PruneTip() (*chainhash.Hash, uint32, error) {
|
||||
var (
|
||||
ctx = context.TODO()
|
||||
@@ -2843,7 +2843,7 @@ func (s *SQLStore) pruneGraphNodes(ctx context.Context,
|
||||
// Channels that were removed from the graph resulting from the
|
||||
// disconnected block are returned.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) DisconnectBlockAtHeight(height uint32) (
|
||||
[]*models.ChannelEdgeInfo, error) {
|
||||
|
||||
@@ -2931,7 +2931,7 @@ func (s *SQLStore) DisconnectBlockAtHeight(height uint32) (
|
||||
|
||||
// AddEdgeProof sets the proof of an existing edge in the graph database.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) AddEdgeProof(scid lnwire.ShortChannelID,
|
||||
proof *models.ChannelAuthProof) error {
|
||||
|
||||
@@ -2981,7 +2981,7 @@ func (s *SQLStore) AddEdgeProof(scid lnwire.ShortChannelID,
|
||||
// that we can ignore channel announcements that we know to be closed without
|
||||
// having to validate them and fetch a block.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) PutClosedScid(scid lnwire.ShortChannelID) error {
|
||||
var (
|
||||
ctx = context.TODO()
|
||||
@@ -2996,7 +2996,7 @@ func (s *SQLStore) PutClosedScid(scid lnwire.ShortChannelID) error {
|
||||
// IsClosedScid checks whether a channel identified by the passed in scid is
|
||||
// closed. This helps avoid having to perform expensive validation checks.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) IsClosedScid(scid lnwire.ShortChannelID) (bool, error) {
|
||||
var (
|
||||
ctx = context.TODO()
|
||||
@@ -3024,7 +3024,7 @@ func (s *SQLStore) IsClosedScid(scid lnwire.ShortChannelID) (bool, error) {
|
||||
// GraphSession will provide the call-back with access to a NodeTraverser
|
||||
// instance which can be used to perform queries against the channel graph.
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
// NOTE: part of the Store interface.
|
||||
func (s *SQLStore) GraphSession(cb func(graph NodeTraverser) error,
|
||||
reset func()) error {
|
||||
|
||||
|
||||
Reference in new issue
Block a user