Skip to content

Commit

Permalink
Merge pull request #151 from blinklabs-io/fix/chainsync-tip
Browse files Browse the repository at this point in the history
fix: properly handle intersect at tip in bulk mode in chainsync input
  • Loading branch information
agaffney authored Jan 1, 2024
2 parents ef72ad8 + 40d4c3c commit 9f53557
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/blinklabs-io/snek
go 1.20

require (
github.com/blinklabs-io/gouroboros v0.67.1
github.com/blinklabs-io/gouroboros v0.69.2
github.com/gen2brain/beeep v0.0.0-20230602101333-f384c29b62dd
github.com/gin-gonic/gin v1.9.1
github.com/kelseyhightower/envconfig v1.4.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGB
cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA=
github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE=
github.com/blinklabs-io/gouroboros v0.67.1 h1:SyzxCIEa2rph3KQr1D+PgqsPNFORN/OdwNtrL0h42g8=
github.com/blinklabs-io/gouroboros v0.67.1/go.mod h1:Q154NJPs7gB93Tggt8ts9RGIlW2kkknr6M90Q3jh0s4=
github.com/blinklabs-io/gouroboros v0.69.2 h1:6FQwC1KxTPYbbugolNU03Dvm3vaCZWoceaaWLx6Skw0=
github.com/blinklabs-io/gouroboros v0.69.2/go.mod h1:ppm97qgdO1ZsfrrziSgmRRChtESfLtGaUcn9UN1Ft5A=
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
github.com/bytedance/sonic v1.10.0-rc/go.mod h1:ElCzW+ufi8qKqNW0FY314xriJhyJhuoJ3gFZdAHF7NM=
github.com/bytedance/sonic v1.10.2 h1:GQebETVBxYB7JGWJtLBi07OVzWwt+8dWA00gEVW2ZFE=
Expand Down
13 changes: 11 additions & 2 deletions input/chainsync/chainsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,24 @@ func (c *ChainSync) Start() error {
c.oConn.BlockFetch().Client.Start()
}
if c.bulkMode && !c.intersectTip && c.oConn.BlockFetch() != nil {
// Get available block range between our intersect point(s) and the chain tip
var err error
c.bulkRangeStart, c.bulkRangeEnd, err = c.oConn.ChainSync().Client.GetAvailableBlockRange(
c.intersectPoints,
)
if err != nil {
return err
}
if err := c.oConn.BlockFetch().Client.GetBlockRange(c.bulkRangeStart, c.bulkRangeEnd); err != nil {
return err
if c.bulkRangeStart.Slot == 0 || c.bulkRangeEnd.Slot == 0 {
// We're already at chain tip, so start a normal sync
if err := c.oConn.ChainSync().Client.Sync(c.intersectPoints); err != nil {
return err
}
} else {
// Use BlockFetch to request the entire available block range at once
if err := c.oConn.BlockFetch().Client.GetBlockRange(c.bulkRangeStart, c.bulkRangeEnd); err != nil {
return err
}
}
} else {
if c.intersectTip {
Expand Down

0 comments on commit 9f53557

Please sign in to comment.