mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-11-24 22:45:50 +00:00
Extract virtualResolveChunk constant
This commit is contained in:
parent
a5be6afd9c
commit
4d3dce456c
@ -64,6 +64,12 @@ type consensus struct {
|
|||||||
virtualNotUpdated bool
|
virtualNotUpdated bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// In order to prevent a situation that the consensus lock is held for too much time, we
|
||||||
|
// release the lock each time we resolve 100 blocks.
|
||||||
|
// Note: `virtualResolveChunk` should be smaller than `params.FinalityDuration` in order to avoid a situation
|
||||||
|
// where UpdatePruningPointByVirtual skips a pruning point.
|
||||||
|
const virtualResolveChunk = 100
|
||||||
|
|
||||||
func (s *consensus) ValidateAndInsertBlockWithTrustedData(block *externalapi.BlockWithTrustedData, validateUTXO bool) error {
|
func (s *consensus) ValidateAndInsertBlockWithTrustedData(block *externalapi.BlockWithTrustedData, validateUTXO bool) error {
|
||||||
s.lock.Lock()
|
s.lock.Lock()
|
||||||
defer s.lock.Unlock()
|
defer s.lock.Unlock()
|
||||||
@ -200,8 +206,7 @@ func (s *consensus) ValidateAndInsertBlock(block *externalapi.DomainBlock, updat
|
|||||||
if s.virtualNotUpdated {
|
if s.virtualNotUpdated {
|
||||||
// We enter the loop in locked state
|
// We enter the loop in locked state
|
||||||
for {
|
for {
|
||||||
// See comment about the const used at `ResolveVirtual`
|
_, isCompletelyResolved, err := s.resolveVirtualChunkNoLock(virtualResolveChunk)
|
||||||
_, isCompletelyResolved, err := s.resolveVirtualChunkNoLock(100)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.lock.Unlock()
|
s.lock.Unlock()
|
||||||
return err
|
return err
|
||||||
@ -930,11 +935,7 @@ func (s *consensus) ResolveVirtual(progressReportCallback func(uint64, uint64))
|
|||||||
progressReportCallback(virtualDAAScoreStart, virtualDAAScore)
|
progressReportCallback(virtualDAAScoreStart, virtualDAAScore)
|
||||||
}
|
}
|
||||||
|
|
||||||
// In order to prevent a situation that the consensus lock is held for too much time, we
|
_, isCompletelyResolved, err := s.resolveVirtualChunkWithLock(virtualResolveChunk)
|
||||||
// release the lock each time we resolve 100 blocks.
|
|
||||||
// Note: maxBlocksToResolve should be smaller than `params.FinalityDuration` in order to avoid a situation
|
|
||||||
// where UpdatePruningPointByVirtual skips a pruning point.
|
|
||||||
_, isCompletelyResolved, err := s.resolveVirtualChunkWithLock(100)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user