Skip to content

Commit

Permalink
Merge pull request #50 from SiaFoundation/dependabot/go_modules/go.et…
Browse files Browse the repository at this point in the history
…cd.io/bbolt-1.3.10

build(deps): bump go.etcd.io/bbolt from 1.3.9 to 1.3.10
  • Loading branch information
ChrisSchinnerl authored May 6, 2024
2 parents 5df7ad9 + faab4a9 commit 3ad6f0a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
14 changes: 7 additions & 7 deletions chain/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (m *Manager) History() ([32]types.BlockID, error) {
// present in the best chain (or, if no match is found, genesis). It also
// returns the number of blocks between the end of the returned slice and the
// current tip.
func (m *Manager) BlocksForHistory(history []types.BlockID, max uint64) ([]types.Block, uint64, error) {
func (m *Manager) BlocksForHistory(history []types.BlockID, maxBlocks uint64) ([]types.Block, uint64, error) {
m.mu.Lock()
defer m.mu.Unlock()
var attachHeight uint64
Expand All @@ -175,10 +175,10 @@ func (m *Manager) BlocksForHistory(history []types.BlockID, max uint64) ([]types
break
}
}
if max > m.tipState.Index.Height-attachHeight {
max = m.tipState.Index.Height - attachHeight
if maxBlocks > m.tipState.Index.Height-attachHeight {
maxBlocks = m.tipState.Index.Height - attachHeight
}
blocks := make([]types.Block, max)
blocks := make([]types.Block, maxBlocks)
for i := range blocks {
index, _ := m.store.BestIndex(attachHeight + uint64(i) + 1)
b, _, ok := m.store.Block(index.ID)
Expand All @@ -187,7 +187,7 @@ func (m *Manager) BlocksForHistory(history []types.BlockID, max uint64) ([]types
}
blocks[i] = b
}
return blocks, m.tipState.Index.Height - (attachHeight + max), nil
return blocks, m.tipState.Index.Height - (attachHeight + maxBlocks), nil
}

// AddBlocks adds a sequence of blocks to a tracked chain. If the blocks are
Expand Down Expand Up @@ -395,15 +395,15 @@ func (m *Manager) reorgTo(index types.ChainIndex) error {

// UpdatesSince returns at most max updates on the path between index and the
// Manager's current tip.
func (m *Manager) UpdatesSince(index types.ChainIndex, max int) (rus []RevertUpdate, aus []ApplyUpdate, err error) {
func (m *Manager) UpdatesSince(index types.ChainIndex, maxBlocks int) (rus []RevertUpdate, aus []ApplyUpdate, err error) {
m.mu.Lock()
defer m.mu.Unlock()
onBestChain := func(index types.ChainIndex) bool {
bi, _ := m.store.BestIndex(index.Height)
return bi.ID == index.ID || index == types.ChainIndex{}
}

for index != m.tipState.Index && len(rus)+len(aus) <= max {
for index != m.tipState.Index && len(rus)+len(aus) <= maxBlocks {
// revert until we are on the best chain, then apply
if !onBestChain(index) {
b, bs, cs, ok := blockAndParent(m.store, index.ID)
Expand Down
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 go.sia.tech/coreutils
go 1.21.6

require (
go.etcd.io/bbolt v1.3.9
go.etcd.io/bbolt v1.3.10
go.sia.tech/core v0.2.3-0.20240416172826-f9d44a4149e1
go.uber.org/zap v1.27.0
golang.org/x/crypto v0.22.0
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
go.etcd.io/bbolt v1.3.9 h1:8x7aARPEXiXbHmtUwAIv7eV2fQFHrLLavdiJ3uzJXoI=
go.etcd.io/bbolt v1.3.9/go.mod h1:zaO32+Ti0PK1ivdPtgMESzuzL2VPoIG1PCQNvOdo/dE=
go.sia.tech/core v0.2.2 h1:33RJrt08o7KyUOY4tITH6ECmRq1lhtapqc/SncIF/2A=
go.sia.tech/core v0.2.2/go.mod h1:Zk7HaybEPgkPC1p6e6tTQr8PIeZClTgNcLNGYDLQJeE=
go.etcd.io/bbolt v1.3.10 h1:+BqfJTcCzTItrop8mq/lbzL8wSGtj94UO/3U31shqG0=
go.etcd.io/bbolt v1.3.10/go.mod h1:bK3UQLPJZly7IlNmV7uVHJDxfe5aK9Ll93e/74Y9oEQ=
go.sia.tech/core v0.2.3-0.20240416172826-f9d44a4149e1 h1:tG9JJk6qPevT2CrFttL9Y4ZIT5+RS3J+Hk9E3zJaGiY=
go.sia.tech/core v0.2.3-0.20240416172826-f9d44a4149e1/go.mod h1:24liZWimivGQF+h3d14ly9oEpMIYxHPSgEMKmunxxi0=
go.sia.tech/mux v1.2.0 h1:ofa1Us9mdymBbGMY2XH/lSpY8itFsKIo/Aq8zwe+GHU=
Expand Down
4 changes: 2 additions & 2 deletions syncer/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ func (p *Peer) RelayV2TransactionSet(index types.ChainIndex, txns []types.V2Tran
// SendV2Blocks requests up to n blocks from p, starting from the most recent
// element of history known to p. The peer also returns the number of remaining
// blocks left to sync.
func (p *Peer) SendV2Blocks(history []types.BlockID, max uint64, timeout time.Duration) ([]types.Block, uint64, error) {
r := &gateway.RPCSendV2Blocks{History: history, Max: max}
func (p *Peer) SendV2Blocks(history []types.BlockID, maxBlocks uint64, timeout time.Duration) ([]types.Block, uint64, error) {
r := &gateway.RPCSendV2Blocks{History: history, Max: maxBlocks}
err := p.callRPC(r, timeout)
return r.Blocks, r.Remaining, err
}
Expand Down

0 comments on commit 3ad6f0a

Please sign in to comment.