Skip to content

Commit

Permalink
chain: fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisSchinnerl committed May 6, 2024
1 parent d0af6e2 commit faab4a9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 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
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 faab4a9

Please sign in to comment.