mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-11 01:11:02 +02:00
graph/db: unexport various methods that expose kvdb.RTx
Unexport the KVStore `FetchOtherNode` and `ForEachNodeChannelTx` methods so that fewer exposed methods are leaking implementation details.
This commit is contained in:
parent
d381f03637
commit
d079f864d2
@ -1219,7 +1219,7 @@ func TestGraphTraversalCacheable(t *testing.T) {
|
|||||||
|
|
||||||
err = graph.db.View(func(tx kvdb.RTx) error {
|
err = graph.db.View(func(tx kvdb.RTx) error {
|
||||||
for _, node := range nodes {
|
for _, node := range nodes {
|
||||||
err := graph.ForEachNodeChannelTx(tx, node,
|
err := graph.forEachNodeChannelTx(tx, node,
|
||||||
func(tx kvdb.RTx, info *models.ChannelEdgeInfo,
|
func(tx kvdb.RTx, info *models.ChannelEdgeInfo,
|
||||||
policy *models.ChannelEdgePolicy,
|
policy *models.ChannelEdgePolicy,
|
||||||
policy2 *models.ChannelEdgePolicy) error { //nolint:ll
|
policy2 *models.ChannelEdgePolicy) error { //nolint:ll
|
||||||
|
@ -561,7 +561,7 @@ func (c *KVStore) ForEachNodeCached(cb func(node route.Vertex,
|
|||||||
|
|
||||||
channels := make(map[uint64]*DirectedChannel)
|
channels := make(map[uint64]*DirectedChannel)
|
||||||
|
|
||||||
err := c.ForEachNodeChannelTx(tx, node.PubKeyBytes,
|
err := c.forEachNodeChannelTx(tx, node.PubKeyBytes,
|
||||||
func(tx kvdb.RTx, e *models.ChannelEdgeInfo,
|
func(tx kvdb.RTx, e *models.ChannelEdgeInfo,
|
||||||
p1 *models.ChannelEdgePolicy,
|
p1 *models.ChannelEdgePolicy,
|
||||||
p2 *models.ChannelEdgePolicy) error {
|
p2 *models.ChannelEdgePolicy) error {
|
||||||
@ -2850,7 +2850,7 @@ func (c *KVStore) isPublic(tx kvdb.RTx, nodePub route.Vertex,
|
|||||||
// used to terminate the check early.
|
// used to terminate the check early.
|
||||||
nodeIsPublic := false
|
nodeIsPublic := false
|
||||||
errDone := errors.New("done")
|
errDone := errors.New("done")
|
||||||
err := c.ForEachNodeChannelTx(tx, nodePub, func(tx kvdb.RTx,
|
err := c.forEachNodeChannelTx(tx, nodePub, func(tx kvdb.RTx,
|
||||||
info *models.ChannelEdgeInfo, _ *models.ChannelEdgePolicy,
|
info *models.ChannelEdgeInfo, _ *models.ChannelEdgePolicy,
|
||||||
_ *models.ChannelEdgePolicy) error {
|
_ *models.ChannelEdgePolicy) error {
|
||||||
|
|
||||||
@ -3132,7 +3132,7 @@ func (c *KVStore) ForEachSourceNodeChannel(cb func(chanPoint wire.OutPoint,
|
|||||||
info *models.ChannelEdgeInfo,
|
info *models.ChannelEdgeInfo,
|
||||||
policy, _ *models.ChannelEdgePolicy) error {
|
policy, _ *models.ChannelEdgePolicy) error {
|
||||||
|
|
||||||
peer, err := c.FetchOtherNode(
|
peer, err := c.fetchOtherNode(
|
||||||
tx, info, node.PubKeyBytes[:],
|
tx, info, node.PubKeyBytes[:],
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -3147,7 +3147,7 @@ func (c *KVStore) ForEachSourceNodeChannel(cb func(chanPoint wire.OutPoint,
|
|||||||
}, func() {})
|
}, func() {})
|
||||||
}
|
}
|
||||||
|
|
||||||
// ForEachNodeChannelTx iterates through all channels of the given node,
|
// forEachNodeChannelTx iterates through all channels of the given node,
|
||||||
// executing the passed callback with an edge info structure and the policies
|
// executing the passed callback with an edge info structure and the policies
|
||||||
// of each end of the channel. The first edge policy is the outgoing edge *to*
|
// of each end of the channel. The first edge policy is the outgoing edge *to*
|
||||||
// the connecting node, while the second is the incoming edge *from* the
|
// the connecting node, while the second is the incoming edge *from* the
|
||||||
@ -3160,7 +3160,7 @@ func (c *KVStore) ForEachSourceNodeChannel(cb func(chanPoint wire.OutPoint,
|
|||||||
// should be passed as the first argument. Otherwise, the first argument should
|
// should be passed as the first argument. Otherwise, the first argument should
|
||||||
// be nil and a fresh transaction will be created to execute the graph
|
// be nil and a fresh transaction will be created to execute the graph
|
||||||
// traversal.
|
// traversal.
|
||||||
func (c *KVStore) ForEachNodeChannelTx(tx kvdb.RTx,
|
func (c *KVStore) forEachNodeChannelTx(tx kvdb.RTx,
|
||||||
nodePub route.Vertex, cb func(kvdb.RTx, *models.ChannelEdgeInfo,
|
nodePub route.Vertex, cb func(kvdb.RTx, *models.ChannelEdgeInfo,
|
||||||
*models.ChannelEdgePolicy,
|
*models.ChannelEdgePolicy,
|
||||||
*models.ChannelEdgePolicy) error) error {
|
*models.ChannelEdgePolicy) error) error {
|
||||||
@ -3168,11 +3168,11 @@ func (c *KVStore) ForEachNodeChannelTx(tx kvdb.RTx,
|
|||||||
return nodeTraversal(tx, nodePub[:], c.db, cb)
|
return nodeTraversal(tx, nodePub[:], c.db, cb)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FetchOtherNode attempts to fetch the full LightningNode that's opposite of
|
// fetchOtherNode attempts to fetch the full LightningNode that's opposite of
|
||||||
// the target node in the channel. This is useful when one knows the pubkey of
|
// the target node in the channel. This is useful when one knows the pubkey of
|
||||||
// one of the nodes, and wishes to obtain the full LightningNode for the other
|
// one of the nodes, and wishes to obtain the full LightningNode for the other
|
||||||
// end of the channel.
|
// end of the channel.
|
||||||
func (c *KVStore) FetchOtherNode(tx kvdb.RTx,
|
func (c *KVStore) fetchOtherNode(tx kvdb.RTx,
|
||||||
channel *models.ChannelEdgeInfo, thisNodeKey []byte) (
|
channel *models.ChannelEdgeInfo, thisNodeKey []byte) (
|
||||||
*models.LightningNode, error) {
|
*models.LightningNode, error) {
|
||||||
|
|
||||||
@ -4702,7 +4702,7 @@ func (c *chanGraphNodeTx) FetchNode(nodePub route.Vertex) (NodeRTx, error) {
|
|||||||
func (c *chanGraphNodeTx) ForEachChannel(f func(*models.ChannelEdgeInfo,
|
func (c *chanGraphNodeTx) ForEachChannel(f func(*models.ChannelEdgeInfo,
|
||||||
*models.ChannelEdgePolicy, *models.ChannelEdgePolicy) error) error {
|
*models.ChannelEdgePolicy, *models.ChannelEdgePolicy) error) error {
|
||||||
|
|
||||||
return c.db.ForEachNodeChannelTx(c.tx, c.node.PubKeyBytes,
|
return c.db.forEachNodeChannelTx(c.tx, c.node.PubKeyBytes,
|
||||||
func(_ kvdb.RTx, info *models.ChannelEdgeInfo, policy1,
|
func(_ kvdb.RTx, info *models.ChannelEdgeInfo, policy1,
|
||||||
policy2 *models.ChannelEdgePolicy) error {
|
policy2 *models.ChannelEdgePolicy) error {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user