routing: include the channel point of chan within edge update ntfn
This commit modifies the `ChannelEdgeUpdate` struct to include the channel point itself within the notifications. Such a change improves the notificaiton experience for callers as it allows them to filter out update notifications based on a familiar object within the codebase: a channel point.
This commit is contained in:
parent
61991a1c89
commit
f6ab1390ed
@ -18,8 +18,10 @@ import (
|
|||||||
// TopologyChanges channel will be sent upon with new updates to the channel
|
// TopologyChanges channel will be sent upon with new updates to the channel
|
||||||
// graph in real-time as they're encountered.
|
// graph in real-time as they're encountered.
|
||||||
type TopologyClient struct {
|
type TopologyClient struct {
|
||||||
// TopologyChanges is a recieve only channel that new channel graph
|
// TopologyChanges is a receive only channel that new channel graph
|
||||||
// updates will be sent over.
|
// updates will be sent over.
|
||||||
|
//
|
||||||
|
// TODO(roasbeef): chan for each update type instead?
|
||||||
TopologyChanges <-chan *TopologyChange
|
TopologyChanges <-chan *TopologyChange
|
||||||
|
|
||||||
// Cancel is a function closure that should be executed when the client
|
// Cancel is a function closure that should be executed when the client
|
||||||
@ -225,6 +227,10 @@ type ChannelEdgeUpdate struct {
|
|||||||
// originally confirmed.
|
// originally confirmed.
|
||||||
ChanID uint64
|
ChanID uint64
|
||||||
|
|
||||||
|
// ChanPoint is the outpoint which represents the multi-sig funding
|
||||||
|
// output for the channel.
|
||||||
|
ChanPoint wire.OutPoint
|
||||||
|
|
||||||
// Capacity is the capacity of the newly created channel.
|
// Capacity is the capacity of the newly created channel.
|
||||||
Capacity btcutil.Amount
|
Capacity btcutil.Amount
|
||||||
|
|
||||||
@ -300,6 +306,7 @@ func addToTopologyChange(graph *channeldb.ChannelGraph, update *TopologyChange,
|
|||||||
|
|
||||||
edgeUpdate := &ChannelEdgeUpdate{
|
edgeUpdate := &ChannelEdgeUpdate{
|
||||||
ChanID: chanID,
|
ChanID: chanID,
|
||||||
|
ChanPoint: edgeInfo.ChannelPoint,
|
||||||
TimeLockDelta: m.TimeLockDelta,
|
TimeLockDelta: m.TimeLockDelta,
|
||||||
Capacity: edgeInfo.Capacity,
|
Capacity: edgeInfo.Capacity,
|
||||||
MinHTLC: btcutil.Amount(m.HtlcMinimumMsat),
|
MinHTLC: btcutil.Amount(m.HtlcMinimumMsat),
|
||||||
|
@ -340,7 +340,7 @@ func TestEdgeUpdateNotification(t *testing.T) {
|
|||||||
|
|
||||||
// First we'll create the utxo for the channel to be "closed"
|
// First we'll create the utxo for the channel to be "closed"
|
||||||
const chanValue = btcutil.Amount(10000)
|
const chanValue = btcutil.Amount(10000)
|
||||||
fundingTx, _, chanID := randChannelEdge(ctx, chanValue,
|
fundingTx, chanPoint, chanID := randChannelEdge(ctx, chanValue,
|
||||||
startingBlockHeight)
|
startingBlockHeight)
|
||||||
|
|
||||||
// We'll also add a record for the block that included our funding
|
// We'll also add a record for the block that included our funding
|
||||||
@ -404,6 +404,10 @@ func TestEdgeUpdateNotification(t *testing.T) {
|
|||||||
t.Fatalf("channel ID of edge doesn't match: "+
|
t.Fatalf("channel ID of edge doesn't match: "+
|
||||||
"expected %v, got %v", chanID.ToUint64(), edgeUpdate.ChanID)
|
"expected %v, got %v", chanID.ToUint64(), edgeUpdate.ChanID)
|
||||||
}
|
}
|
||||||
|
if edgeUpdate.ChanPoint != chanPoint {
|
||||||
|
t.Fatalf("channel don't match: expected %v, got %v",
|
||||||
|
chanPoint, edgeUpdate.ChanPoint)
|
||||||
|
}
|
||||||
// TODO(roasbeef): this is a hack, needs to be removed
|
// TODO(roasbeef): this is a hack, needs to be removed
|
||||||
// after commitment fees are dynamic.
|
// after commitment fees are dynamic.
|
||||||
if edgeUpdate.Capacity != chanValue-5000 {
|
if edgeUpdate.Capacity != chanValue-5000 {
|
||||||
|
Loading…
Reference in New Issue
Block a user