multi: rename ChannelUpdate to ChannelUpdate1
In preparation for adding a new ChannelUpdate2 message and a ChannelUpdate interface, we rename the existing message to ChannelUpdate1.
This commit is contained in:
43 files changed
+198
-172
No files matched your search
@@ -60,7 +60,7 @@ type ChanStatusConfig struct {
|
||||
// ApplyChannelUpdate processes new ChannelUpdates signed by our node by
|
||||
// updating our local routing table and broadcasting the update to our
|
||||
// peers.
|
||||
ApplyChannelUpdate func(*lnwire.ChannelUpdate, *wire.OutPoint,
|
||||
ApplyChannelUpdate func(*lnwire.ChannelUpdate1, *wire.OutPoint,
|
||||
bool) error
|
||||
|
||||
// DB stores the set of channels that are to be monitored.
|
||||
@@ -650,7 +650,7 @@ func (m *ChanStatusManager) signAndSendNextUpdate(outpoint wire.OutPoint,
|
||||
// in case our ChannelEdgePolicy is not found in the database. Also returns if
|
||||
// the channel is private by checking AuthProof for nil.
|
||||
func (m *ChanStatusManager) fetchLastChanUpdateByOutPoint(op wire.OutPoint) (
|
||||
*lnwire.ChannelUpdate, bool, error) {
|
||||
*lnwire.ChannelUpdate1, bool, error) {
|
||||
|
||||
// Get the edge info and policies for this channel from the graph.
|
||||
info, edge1, edge2, err := m.cfg.Graph.FetchChannelEdgesByOutpoint(&op)
|
||||
|
||||
@@ -126,7 +126,7 @@ type mockGraph struct {
|
||||
chanPols2 map[wire.OutPoint]*models.ChannelEdgePolicy
|
||||
sidToCid map[lnwire.ShortChannelID]wire.OutPoint
|
||||
|
||||
updates chan *lnwire.ChannelUpdate
|
||||
updates chan *lnwire.ChannelUpdate1
|
||||
}
|
||||
|
||||
func newMockGraph(t *testing.T, numChannels int,
|
||||
@@ -138,7 +138,7 @@ func newMockGraph(t *testing.T, numChannels int,
|
||||
chanPols1: make(map[wire.OutPoint]*models.ChannelEdgePolicy),
|
||||
chanPols2: make(map[wire.OutPoint]*models.ChannelEdgePolicy),
|
||||
sidToCid: make(map[lnwire.ShortChannelID]wire.OutPoint),
|
||||
updates: make(chan *lnwire.ChannelUpdate, 2*numChannels),
|
||||
updates: make(chan *lnwire.ChannelUpdate1, 2*numChannels),
|
||||
}
|
||||
|
||||
for i := 0; i < numChannels; i++ {
|
||||
@@ -177,7 +177,7 @@ func (g *mockGraph) FetchChannelEdgesByOutpoint(
|
||||
return info, pol1, pol2, nil
|
||||
}
|
||||
|
||||
func (g *mockGraph) ApplyChannelUpdate(update *lnwire.ChannelUpdate,
|
||||
func (g *mockGraph) ApplyChannelUpdate(update *lnwire.ChannelUpdate1,
|
||||
op *wire.OutPoint, private bool) error {
|
||||
|
||||
g.mu.Lock()
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
func CreateChanAnnouncement(chanProof *models.ChannelAuthProof,
|
||||
chanInfo *models.ChannelEdgeInfo,
|
||||
e1, e2 *models.ChannelEdgePolicy) (*lnwire.ChannelAnnouncement1,
|
||||
*lnwire.ChannelUpdate, *lnwire.ChannelUpdate, error) {
|
||||
*lnwire.ChannelUpdate1, *lnwire.ChannelUpdate1, error) {
|
||||
|
||||
// First, using the parameters of the channel, along with the channel
|
||||
// authentication chanProof, we'll create re-create the original
|
||||
@@ -68,7 +68,7 @@ func CreateChanAnnouncement(chanProof *models.ChannelAuthProof,
|
||||
// Since it's up to a node's policy as to whether they advertise the
|
||||
// edge in a direction, we don't create an advertisement if the edge is
|
||||
// nil.
|
||||
var edge1Ann, edge2Ann *lnwire.ChannelUpdate
|
||||
var edge1Ann, edge2Ann *lnwire.ChannelUpdate1
|
||||
if e1 != nil {
|
||||
edge1Ann, err = ChannelUpdateFromEdge(chanInfo, e1)
|
||||
if err != nil {
|
||||
|
||||
@@ -18,12 +18,12 @@ var ErrUnableToExtractChanUpdate = fmt.Errorf("unable to extract ChannelUpdate")
|
||||
|
||||
// ChannelUpdateModifier is a closure that makes in-place modifications to an
|
||||
// lnwire.ChannelUpdate.
|
||||
type ChannelUpdateModifier func(*lnwire.ChannelUpdate)
|
||||
type ChannelUpdateModifier func(*lnwire.ChannelUpdate1)
|
||||
|
||||
// ChanUpdSetDisable is a functional option that sets the disabled channel flag
|
||||
// if disabled is true, and clears the bit otherwise.
|
||||
func ChanUpdSetDisable(disabled bool) ChannelUpdateModifier {
|
||||
return func(update *lnwire.ChannelUpdate) {
|
||||
return func(update *lnwire.ChannelUpdate1) {
|
||||
if disabled {
|
||||
// Set the bit responsible for marking a channel as
|
||||
// disabled.
|
||||
@@ -39,7 +39,7 @@ func ChanUpdSetDisable(disabled bool) ChannelUpdateModifier {
|
||||
// ChanUpdSetTimestamp is a functional option that sets the timestamp of the
|
||||
// update to the current time, or increments it if the timestamp is already in
|
||||
// the future.
|
||||
func ChanUpdSetTimestamp(update *lnwire.ChannelUpdate) {
|
||||
func ChanUpdSetTimestamp(update *lnwire.ChannelUpdate1) {
|
||||
newTimestamp := uint32(time.Now().Unix())
|
||||
if newTimestamp <= update.Timestamp {
|
||||
// Increment the prior value to ensure the timestamp
|
||||
@@ -57,7 +57,7 @@ func ChanUpdSetTimestamp(update *lnwire.ChannelUpdate) {
|
||||
//
|
||||
// NOTE: This method modifies the given update.
|
||||
func SignChannelUpdate(signer lnwallet.MessageSigner, keyLoc keychain.KeyLocator,
|
||||
update *lnwire.ChannelUpdate, mods ...ChannelUpdateModifier) error {
|
||||
update *lnwire.ChannelUpdate1, mods ...ChannelUpdateModifier) error {
|
||||
|
||||
// Apply the requested changes to the channel update.
|
||||
for _, modifier := range mods {
|
||||
@@ -86,7 +86,7 @@ func SignChannelUpdate(signer lnwallet.MessageSigner, keyLoc keychain.KeyLocator
|
||||
func ExtractChannelUpdate(ownerPubKey []byte,
|
||||
info *models.ChannelEdgeInfo,
|
||||
policies ...*models.ChannelEdgePolicy) (
|
||||
*lnwire.ChannelUpdate, error) {
|
||||
*lnwire.ChannelUpdate1, error) {
|
||||
|
||||
// Helper function to extract the owner of the given policy.
|
||||
owner := func(edge *models.ChannelEdgePolicy) []byte {
|
||||
@@ -118,9 +118,9 @@ func ExtractChannelUpdate(ownerPubKey []byte,
|
||||
// UnsignedChannelUpdateFromEdge reconstructs an unsigned ChannelUpdate from the
|
||||
// given edge info and policy.
|
||||
func UnsignedChannelUpdateFromEdge(info *models.ChannelEdgeInfo,
|
||||
policy *models.ChannelEdgePolicy) *lnwire.ChannelUpdate {
|
||||
policy *models.ChannelEdgePolicy) *lnwire.ChannelUpdate1 {
|
||||
|
||||
return &lnwire.ChannelUpdate{
|
||||
return &lnwire.ChannelUpdate1{
|
||||
ChainHash: info.ChainHash,
|
||||
ShortChannelID: lnwire.NewShortChanIDFromInt(policy.ChannelID),
|
||||
Timestamp: uint32(policy.LastUpdate.Unix()),
|
||||
@@ -138,7 +138,7 @@ func UnsignedChannelUpdateFromEdge(info *models.ChannelEdgeInfo,
|
||||
// ChannelUpdateFromEdge reconstructs a signed ChannelUpdate from the given edge
|
||||
// info and policy.
|
||||
func ChannelUpdateFromEdge(info *models.ChannelEdgeInfo,
|
||||
policy *models.ChannelEdgePolicy) (*lnwire.ChannelUpdate, error) {
|
||||
policy *models.ChannelEdgePolicy) (*lnwire.ChannelUpdate1, error) {
|
||||
|
||||
update := UnsignedChannelUpdateFromEdge(info, policy)
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ func TestUpdateDisableFlag(t *testing.T) {
|
||||
// Create the initial update, the only fields we are
|
||||
// concerned with in this test are the timestamp and the
|
||||
// channel flags.
|
||||
ogUpdate := &lnwire.ChannelUpdate{
|
||||
ogUpdate := &lnwire.ChannelUpdate1{
|
||||
Timestamp: uint32(tc.startTime.Unix()),
|
||||
}
|
||||
if !tc.startEnabled {
|
||||
@@ -122,7 +122,7 @@ func TestUpdateDisableFlag(t *testing.T) {
|
||||
// the original. UpdateDisableFlag will mutate the
|
||||
// passed channel update, so we keep the old one to test
|
||||
// against.
|
||||
newUpdate := &lnwire.ChannelUpdate{
|
||||
newUpdate := &lnwire.ChannelUpdate1{
|
||||
Timestamp: ogUpdate.Timestamp,
|
||||
ChannelFlags: ogUpdate.ChannelFlags,
|
||||
}
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ func SignAnnouncement(signer lnwallet.MessageSigner, keyLoc keychain.KeyLocator,
|
||||
switch m := msg.(type) {
|
||||
case *lnwire.ChannelAnnouncement1:
|
||||
data, err = m.DataToSign()
|
||||
case *lnwire.ChannelUpdate:
|
||||
case *lnwire.ChannelUpdate1:
|
||||
data, err = m.DataToSign()
|
||||
case *lnwire.NodeAnnouncement:
|
||||
data, err = m.DataToSign()
|
||||
|
||||
Reference in new issue
Block a user