Minor comments from PR

This commit is contained in:
Jasmina Malicevic
2022-05-12 14:31:53 +02:00
parent 26e864c7ff
commit 47bd5cc65d
2 changed files with 9 additions and 5 deletions

View File

@@ -238,7 +238,7 @@ func (pool *BlockPool) PopRequest() {
// to smooth the block sync rate and the unit represents the number of blocks per second.
// -1 because the start height is assumed to be 1 @jmalicevic ToDo, verify it is still OK when
// starting height is not 1
if (pool.height-pool.startHeight-1)%100 == 0 {
if (pool.height-pool.startHeight)%100 == 0 && pool.height != pool.startHeight {
newSyncRate := 100 / time.Since(pool.lastHundredBlockTimeStamp).Seconds()
if pool.lastSyncRate == 0 {
pool.lastSyncRate = newSyncRate
@@ -558,11 +558,15 @@ func (peer *bpPeer) onTimeout() {
//-------------------------------------
type BlockResponse struct {
// Trusted Block data stores the last block verified by blocksync
// along with the commit used to verify it.
type TrustedBlockData struct {
block *types.Block
commit *types.Commit
}
//-------------------------------------
type bpRequester struct {
service.BaseService
logger log.Logger

View File

@@ -93,7 +93,7 @@ type Reactor struct {
syncStartTime time.Time
lastTrustedBlock *BlockResponse
lastTrustedBlock *TrustedBlockData
}
// NewReactor returns new reactor instance.
@@ -601,7 +601,7 @@ func (r *Reactor) poolRoutine(ctx context.Context, stateSynced bool, blockSyncCh
} else {
// we need to load the last block we trusted
if r.initialState.LastBlockHeight != 0 {
r.lastTrustedBlock = &BlockResponse{r.store.LoadBlock(r.initialState.LastBlockHeight), r.store.LoadBlockCommit(r.initialState.LastBlockHeight)}
r.lastTrustedBlock = &TrustedBlockData{r.store.LoadBlock(r.initialState.LastBlockHeight), r.store.LoadBlockCommit(r.initialState.LastBlockHeight)}
if r.lastTrustedBlock == nil {
panic("Failed to load last trusted block")
}
@@ -623,7 +623,7 @@ func (r *Reactor) poolRoutine(ctx context.Context, stateSynced bool, blockSyncCh
continue // was return previously
}
r.lastTrustedBlock = &BlockResponse{block: newBlock, commit: verifyBlock.LastCommit}
r.lastTrustedBlock = &TrustedBlockData{block: newBlock, commit: verifyBlock.LastCommit}
}
var err error
// validate the block before we persist it