htlcswitch+channel: add channel states synchronization

In this commit BOLT№2 retranmission logic for the channel link have
been added. Now if channel link have been initialised with the
'SyncState' field than it will send the lnwire.ChannelReestablish
message and will be waiting for receiving the same message from remote
side. Exchange of this message allow both sides understand which
updates they should exchange with each other in order sync their
states.
This commit is contained in:
Andrey Samokhvalov
2017-07-09 02:30:20 +03:00
committed by Olaoluwa Osuntokun
parent bea9c0b52b
commit d70ffe93e4
8 changed files with 1133 additions and 254 deletions

View File

@@ -399,6 +399,7 @@ func (p *peer) loadActiveChannels(chans []*channeldb.OpenChannel) error {
Switch: p.server.htlcSwitch,
FwrdingPolicy: *forwardingPolicy,
BlockEpochs: blockEpoch,
SyncStates: true,
}
link := htlcswitch.NewChannelLink(linkCfg, lnChan,
uint32(currentHeight))
@@ -745,6 +746,9 @@ out:
case *lnwire.UpdateFee:
isChanUpdate = true
targetChan = msg.ChanID
case *lnwire.ChannelReestablish:
isChanUpdate = true
targetChan = msg.ChanID
case *lnwire.ChannelUpdate,
*lnwire.ChannelAnnouncement,
@@ -1261,6 +1265,7 @@ out:
Switch: p.server.htlcSwitch,
FwrdingPolicy: p.server.cc.routingPolicy,
BlockEpochs: blockEpoch,
SyncStates: false,
}
link := htlcswitch.NewChannelLink(linkConfig, newChan,
uint32(currentHeight))