@@ -622,8 +622,12 @@ func (g *GossipSyncer) channelGraphSyncer() {
622
622
if g .localUpdateHorizon == nil &&
623
623
syncType .IsActiveSync () {
624
624
625
+ startBlock := g .cfg .bestHeight ()
626
+ blockRange := uint32 (math .MaxUint32 )
627
+
625
628
err := g .sendGossipTimestampRange (
626
629
time .Now (), math .MaxUint32 ,
630
+ & startBlock , & blockRange ,
627
631
)
628
632
if err != nil {
629
633
log .Errorf ("Unable to send update " +
@@ -690,12 +694,23 @@ func (g *GossipSyncer) replyHandler() {
690
694
// sendGossipTimestampRange constructs and sets a GossipTimestampRange for the
691
695
// syncer and sends it to the remote peer.
692
696
func (g * GossipSyncer ) sendGossipTimestampRange (firstTimestamp time.Time ,
693
- timestampRange uint32 ) error {
697
+ timestampRange uint32 , firstBlock , blockRange * uint32 ) error {
694
698
695
699
endTimestamp := firstTimestamp .Add (
696
700
time .Duration (timestampRange ) * time .Second ,
697
701
)
698
702
703
+ if firstBlock != nil && blockRange != nil {
704
+ log .Infof ("GossipSyncer(%x): applying " +
705
+ "gossipFilter(start-time=%v, end-time=%v, " +
706
+ "start-block=%v, block-range=%v)" , g .cfg .peerPub [:],
707
+ firstTimestamp , endTimestamp , * firstBlock , * blockRange )
708
+ } else {
709
+ log .Infof ("GossipSyncer(%x): applying " +
710
+ "gossipFilter(start-time=%v, end-time=%v" ,
711
+ g .cfg .peerPub [:], firstTimestamp , endTimestamp )
712
+ }
713
+
699
714
log .Infof ("GossipSyncer(%x): applying gossipFilter(start=%v, end=%v)" ,
700
715
g .cfg .peerPub [:], firstTimestamp , endTimestamp )
701
716
@@ -705,11 +720,28 @@ func (g *GossipSyncer) sendGossipTimestampRange(firstTimestamp time.Time,
705
720
TimestampRange : timestampRange ,
706
721
}
707
722
723
+ if firstBlock != nil {
724
+ first := tlv .ZeroRecordT [tlv.TlvType2 , uint32 ]()
725
+ first .Val = * firstBlock
726
+
727
+ localUpdateHorizon .FirstBlockHeight = tlv .SomeRecordT (first )
728
+ }
729
+
730
+ if blockRange != nil {
731
+ bRange := tlv .ZeroRecordT [tlv.TlvType4 , uint32 ]()
732
+ bRange .Val = * blockRange
733
+
734
+ localUpdateHorizon .BlockRange = tlv .SomeRecordT (bRange )
735
+ }
736
+
708
737
if err := g .cfg .sendToPeer (localUpdateHorizon ); err != nil {
709
738
return err
710
739
}
711
740
712
- if firstTimestamp == zeroTimestamp && timestampRange == 0 {
741
+ noTimeStamps := firstTimestamp == zeroTimestamp && timestampRange == 0
742
+ noBlockHeights := firstBlock == nil && blockRange == nil
743
+
744
+ if noTimeStamps && noBlockHeights {
713
745
g .localUpdateHorizon = nil
714
746
} else {
715
747
g .localUpdateHorizon = localUpdateHorizon
@@ -1661,6 +1693,8 @@ func (g *GossipSyncer) handleSyncTransition(req *syncTransitionReq) error {
1661
1693
var (
1662
1694
firstTimestamp time.Time
1663
1695
timestampRange uint32
1696
+ firstBlock * uint32
1697
+ blockRange * uint32
1664
1698
)
1665
1699
1666
1700
switch req .newSyncType {
@@ -1669,6 +1703,10 @@ func (g *GossipSyncer) handleSyncTransition(req *syncTransitionReq) error {
1669
1703
case ActiveSync , PinnedSync :
1670
1704
firstTimestamp = time .Now ()
1671
1705
timestampRange = math .MaxUint32
1706
+ bestHeight := g .cfg .bestHeight ()
1707
+ firstBlock = & bestHeight
1708
+ heightRange := uint32 (math .MaxUint32 )
1709
+ blockRange = & heightRange
1672
1710
1673
1711
// If a PassiveSync transition has been requested, then we should no
1674
1712
// longer receive any new updates from the remote peer. We can do this
@@ -1683,7 +1721,9 @@ func (g *GossipSyncer) handleSyncTransition(req *syncTransitionReq) error {
1683
1721
req .newSyncType )
1684
1722
}
1685
1723
1686
- err := g .sendGossipTimestampRange (firstTimestamp , timestampRange )
1724
+ err := g .sendGossipTimestampRange (
1725
+ firstTimestamp , timestampRange , firstBlock , blockRange ,
1726
+ )
1687
1727
if err != nil {
1688
1728
return fmt .Errorf ("unable to send local update horizon: %w" ,
1689
1729
err )
0 commit comments