discovery: update to recent lnwire.ChannelUpdate changes

This commit is contained in:
Olaoluwa Osuntokun 2017-06-16 22:48:07 +02:00
parent 319afb14f1
commit 1c0712ca03
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
3 changed files with 37 additions and 31 deletions

@ -263,6 +263,12 @@ func (d *AuthenticatedGossiper) ProcessLocalAnnouncement(msg lnwire.Message,
func (d *AuthenticatedGossiper) networkHandler() { func (d *AuthenticatedGossiper) networkHandler() {
defer d.wg.Done() defer d.wg.Done()
// TODO(roasbeef): changes for spec compliance
// * make into de-duplicated struct
// * always send chan ann -> node ann -> chan update
// * buffer recv'd node ann until after chan ann that includes is
// created
// * can use mostly empty struct in db as place holder
var announcementBatch []lnwire.Message var announcementBatch []lnwire.Message
// TODO(roasbeef): parametrize the above // TODO(roasbeef): parametrize the above
@ -366,14 +372,14 @@ func (d *AuthenticatedGossiper) networkHandler() {
// announcements array. // announcements array.
err := d.cfg.Router.ForAllOutgoingChannels(func(p *channeldb.ChannelEdgePolicy) error { err := d.cfg.Router.ForAllOutgoingChannels(func(p *channeldb.ChannelEdgePolicy) error {
c := &lnwire.ChannelUpdate{ c := &lnwire.ChannelUpdate{
Signature: p.Signature, Signature: p.Signature,
ShortChannelID: lnwire.NewShortChanIDFromInt(p.ChannelID), ShortChannelID: lnwire.NewShortChanIDFromInt(p.ChannelID),
Timestamp: uint32(p.LastUpdate.Unix()), Timestamp: uint32(p.LastUpdate.Unix()),
Flags: p.Flags, Flags: p.Flags,
TimeLockDelta: p.TimeLockDelta, TimeLockDelta: p.TimeLockDelta,
HtlcMinimumMsat: uint32(p.MinHTLC), HtlcMinimumMsat: uint64(p.MinHTLC),
FeeBaseMsat: uint32(p.FeeBaseMSat), BaseFee: uint32(p.FeeBaseMSat),
FeeProportionalMillionths: uint32(p.FeeProportionalMillionths), FeeRate: uint32(p.FeeProportionalMillionths),
} }
selfChans = append(selfChans, c) selfChans = append(selfChans, c)
return nil return nil
@ -621,8 +627,8 @@ func (d *AuthenticatedGossiper) processNetworkAnnouncement(nMsg *networkMsg) []l
Flags: msg.Flags, Flags: msg.Flags,
TimeLockDelta: msg.TimeLockDelta, TimeLockDelta: msg.TimeLockDelta,
MinHTLC: btcutil.Amount(msg.HtlcMinimumMsat), MinHTLC: btcutil.Amount(msg.HtlcMinimumMsat),
FeeBaseMSat: btcutil.Amount(msg.FeeBaseMsat), FeeBaseMSat: btcutil.Amount(msg.BaseFee),
FeeProportionalMillionths: btcutil.Amount(msg.FeeProportionalMillionths), FeeProportionalMillionths: btcutil.Amount(msg.FeeRate),
} }
if err := d.cfg.Router.UpdateEdge(update); err != nil { if err := d.cfg.Router.UpdateEdge(update); err != nil {

@ -337,11 +337,11 @@ func createUpdateAnnouncement(blockHeight uint32) (*lnwire.ChannelUpdate, error)
ShortChannelID: lnwire.ShortChannelID{ ShortChannelID: lnwire.ShortChannelID{
BlockHeight: blockHeight, BlockHeight: blockHeight,
}, },
Timestamp: uint32(prand.Int31()), Timestamp: uint32(prand.Int31()),
TimeLockDelta: uint16(prand.Int63()), TimeLockDelta: uint16(prand.Int63()),
HtlcMinimumMsat: uint32(prand.Int31()), HtlcMinimumMsat: uint64(prand.Int63()),
FeeBaseMsat: uint32(prand.Int31()), FeeRate: uint32(prand.Int31()),
FeeProportionalMillionths: uint32(prand.Int31()), BaseFee: uint32(prand.Int31()),
} }
pub := nodeKeyPriv1.PubKey() pub := nodeKeyPriv1.PubKey()

@ -44,26 +44,26 @@ func createChanAnnouncement(chanProof *channeldb.ChannelAuthProof,
var edge1Ann, edge2Ann *lnwire.ChannelUpdate var edge1Ann, edge2Ann *lnwire.ChannelUpdate
if e1 != nil { if e1 != nil {
edge1Ann = &lnwire.ChannelUpdate{ edge1Ann = &lnwire.ChannelUpdate{
Signature: e1.Signature, Signature: e1.Signature,
ShortChannelID: chanID, ShortChannelID: chanID,
Timestamp: uint32(e1.LastUpdate.Unix()), Timestamp: uint32(e1.LastUpdate.Unix()),
Flags: 0, Flags: 0,
TimeLockDelta: e1.TimeLockDelta, TimeLockDelta: e1.TimeLockDelta,
HtlcMinimumMsat: uint32(e1.MinHTLC), HtlcMinimumMsat: uint64(e1.MinHTLC),
FeeBaseMsat: uint32(e1.FeeBaseMSat), BaseFee: uint32(e1.FeeBaseMSat),
FeeProportionalMillionths: uint32(e1.FeeProportionalMillionths), FeeRate: uint32(e1.FeeProportionalMillionths),
} }
} }
if e2 != nil { if e2 != nil {
edge2Ann = &lnwire.ChannelUpdate{ edge2Ann = &lnwire.ChannelUpdate{
Signature: e2.Signature, Signature: e2.Signature,
ShortChannelID: chanID, ShortChannelID: chanID,
Timestamp: uint32(e2.LastUpdate.Unix()), Timestamp: uint32(e2.LastUpdate.Unix()),
Flags: 1, Flags: 1,
TimeLockDelta: e2.TimeLockDelta, TimeLockDelta: e2.TimeLockDelta,
HtlcMinimumMsat: uint32(e2.MinHTLC), HtlcMinimumMsat: uint64(e2.MinHTLC),
FeeBaseMsat: uint32(e2.FeeBaseMSat), BaseFee: uint32(e2.FeeBaseMSat),
FeeProportionalMillionths: uint32(e2.FeeProportionalMillionths), FeeRate: uint32(e2.FeeProportionalMillionths),
} }
} }