Skip to content

Commit 9f53557

Browse files
authored
Merge pull request #151 from blinklabs-io/fix/chainsync-tip
fix: properly handle intersect at tip in bulk mode in chainsync input
2 parents ef72ad8 + 40d4c3c commit 9f53557

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/blinklabs-io/snek
33
go 1.20
44

55
require (
6-
github.com/blinklabs-io/gouroboros v0.67.1
6+
github.com/blinklabs-io/gouroboros v0.69.2
77
github.com/gen2brain/beeep v0.0.0-20230602101333-f384c29b62dd
88
github.com/gin-gonic/gin v1.9.1
99
github.com/kelseyhightower/envconfig v1.4.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGB
44
cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA=
55
github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
66
github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE=
7-
github.com/blinklabs-io/gouroboros v0.67.1 h1:SyzxCIEa2rph3KQr1D+PgqsPNFORN/OdwNtrL0h42g8=
8-
github.com/blinklabs-io/gouroboros v0.67.1/go.mod h1:Q154NJPs7gB93Tggt8ts9RGIlW2kkknr6M90Q3jh0s4=
7+
github.com/blinklabs-io/gouroboros v0.69.2 h1:6FQwC1KxTPYbbugolNU03Dvm3vaCZWoceaaWLx6Skw0=
8+
github.com/blinklabs-io/gouroboros v0.69.2/go.mod h1:ppm97qgdO1ZsfrrziSgmRRChtESfLtGaUcn9UN1Ft5A=
99
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
1010
github.com/bytedance/sonic v1.10.0-rc/go.mod h1:ElCzW+ufi8qKqNW0FY314xriJhyJhuoJ3gFZdAHF7NM=
1111
github.com/bytedance/sonic v1.10.2 h1:GQebETVBxYB7JGWJtLBi07OVzWwt+8dWA00gEVW2ZFE=

input/chainsync/chainsync.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,24 @@ func (c *ChainSync) Start() error {
9292
c.oConn.BlockFetch().Client.Start()
9393
}
9494
if c.bulkMode && !c.intersectTip && c.oConn.BlockFetch() != nil {
95+
// Get available block range between our intersect point(s) and the chain tip
9596
var err error
9697
c.bulkRangeStart, c.bulkRangeEnd, err = c.oConn.ChainSync().Client.GetAvailableBlockRange(
9798
c.intersectPoints,
9899
)
99100
if err != nil {
100101
return err
101102
}
102-
if err := c.oConn.BlockFetch().Client.GetBlockRange(c.bulkRangeStart, c.bulkRangeEnd); err != nil {
103-
return err
103+
if c.bulkRangeStart.Slot == 0 || c.bulkRangeEnd.Slot == 0 {
104+
// We're already at chain tip, so start a normal sync
105+
if err := c.oConn.ChainSync().Client.Sync(c.intersectPoints); err != nil {
106+
return err
107+
}
108+
} else {
109+
// Use BlockFetch to request the entire available block range at once
110+
if err := c.oConn.BlockFetch().Client.GetBlockRange(c.bulkRangeStart, c.bulkRangeEnd); err != nil {
111+
return err
112+
}
104113
}
105114
} else {
106115
if c.intersectTip {

0 commit comments

Comments
 (0)