@@ -627,8 +627,12 @@ func (g *GossipSyncer) channelGraphSyncer() {
627
627
if g .localUpdateHorizon == nil &&
628
628
syncType .IsActiveSync () {
629
629
630
+ startBlock := g .cfg .bestHeight ()
631
+ blockRange := uint32 (math .MaxUint32 )
632
+
630
633
err := g .sendGossipTimestampRange (
631
634
time .Now (), math .MaxUint32 ,
635
+ & startBlock , & blockRange ,
632
636
)
633
637
if err != nil {
634
638
log .Errorf ("Unable to send update " +
@@ -695,12 +699,23 @@ func (g *GossipSyncer) replyHandler() {
695
699
// sendGossipTimestampRange constructs and sets a GossipTimestampRange for the
696
700
// syncer and sends it to the remote peer.
697
701
func (g * GossipSyncer ) sendGossipTimestampRange (firstTimestamp time.Time ,
698
- timestampRange uint32 ) error {
702
+ timestampRange uint32 , firstBlock , blockRange * uint32 ) error {
699
703
700
704
endTimestamp := firstTimestamp .Add (
701
705
time .Duration (timestampRange ) * time .Second ,
702
706
)
703
707
708
+ if firstBlock != nil && blockRange != nil {
709
+ log .Infof ("GossipSyncer(%x): applying " +
710
+ "gossipFilter(start-time=%v, end-time=%v, " +
711
+ "start-block=%v, block-range=%v)" , g .cfg .peerPub [:],
712
+ firstTimestamp , endTimestamp , * firstBlock , * blockRange )
713
+ } else {
714
+ log .Infof ("GossipSyncer(%x): applying " +
715
+ "gossipFilter(start-time=%v, end-time=%v" ,
716
+ g .cfg .peerPub [:], firstTimestamp , endTimestamp )
717
+ }
718
+
704
719
log .Infof ("GossipSyncer(%x): applying gossipFilter(start=%v, end=%v)" ,
705
720
g .cfg .peerPub [:], firstTimestamp , endTimestamp )
706
721
@@ -710,11 +725,28 @@ func (g *GossipSyncer) sendGossipTimestampRange(firstTimestamp time.Time,
710
725
TimestampRange : timestampRange ,
711
726
}
712
727
728
+ if firstBlock != nil {
729
+ first := tlv .ZeroRecordT [tlv.TlvType2 , uint32 ]()
730
+ first .Val = * firstBlock
731
+
732
+ localUpdateHorizon .FirstBlockHeight = tlv .SomeRecordT (first )
733
+ }
734
+
735
+ if blockRange != nil {
736
+ bRange := tlv .ZeroRecordT [tlv.TlvType4 , uint32 ]()
737
+ bRange .Val = * blockRange
738
+
739
+ localUpdateHorizon .BlockRange = tlv .SomeRecordT (bRange )
740
+ }
741
+
713
742
if err := g .cfg .sendToPeer (localUpdateHorizon ); err != nil {
714
743
return err
715
744
}
716
745
717
- if firstTimestamp == zeroTimestamp && timestampRange == 0 {
746
+ noTimeStamps := firstTimestamp == zeroTimestamp && timestampRange == 0
747
+ noBlockHeights := firstBlock == nil && blockRange == nil
748
+
749
+ if noTimeStamps && noBlockHeights {
718
750
g .localUpdateHorizon = nil
719
751
} else {
720
752
g .localUpdateHorizon = localUpdateHorizon
@@ -1624,6 +1656,8 @@ func (g *GossipSyncer) handleSyncTransition(req *syncTransitionReq) error {
1624
1656
var (
1625
1657
firstTimestamp time.Time
1626
1658
timestampRange uint32
1659
+ firstBlock * uint32
1660
+ blockRange * uint32
1627
1661
)
1628
1662
1629
1663
switch req .newSyncType {
@@ -1632,6 +1666,10 @@ func (g *GossipSyncer) handleSyncTransition(req *syncTransitionReq) error {
1632
1666
case ActiveSync , PinnedSync :
1633
1667
firstTimestamp = time .Now ()
1634
1668
timestampRange = math .MaxUint32
1669
+ bestHeight := g .cfg .bestHeight ()
1670
+ firstBlock = & bestHeight
1671
+ heightRange := uint32 (math .MaxUint32 )
1672
+ blockRange = & heightRange
1635
1673
1636
1674
// If a PassiveSync transition has been requested, then we should no
1637
1675
// longer receive any new updates from the remote peer. We can do this
@@ -1646,7 +1684,9 @@ func (g *GossipSyncer) handleSyncTransition(req *syncTransitionReq) error {
1646
1684
req .newSyncType )
1647
1685
}
1648
1686
1649
- err := g .sendGossipTimestampRange (firstTimestamp , timestampRange )
1687
+ err := g .sendGossipTimestampRange (
1688
+ firstTimestamp , timestampRange , firstBlock , blockRange ,
1689
+ )
1650
1690
if err != nil {
1651
1691
return fmt .Errorf ("unable to send local update horizon: %v" , err )
1652
1692
}
0 commit comments