* Add logs

* Fix logInterval to const
This commit is contained in:
Ori Newman 2021-01-04 17:04:13 +02:00 committed by GitHub
parent 789a7379bd
commit 0fb97a4f37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -2,6 +2,7 @@ package consensus
import (
"github.com/kaspanet/kaspad/infrastructure/db/database"
"github.com/kaspanet/kaspad/infrastructure/logger"
"sync"
"github.com/kaspanet/kaspad/domain/consensus/model"
@ -374,6 +375,9 @@ func (s *consensus) GetHeadersSelectedTip() (*externalapi.DomainHash, error) {
}
func (s *consensus) GetVirtualUTXOSet() ([]*externalapi.OutpointUTXOPair, error) {
onEnd := logger.LogAndMeasureExecutionTime(log, "consensus.GetVirtualUTXOSet")
defer onEnd()
s.lock.Lock()
defer s.lock.Unlock()

View File

@ -309,11 +309,15 @@ func (uis *utxoIndexStore) replaceUTXOSet(utxoSet []*externalapi.OutpointUTXOPai
}
uis.virtualSelectedParent = virtualSelectedParent
for _, pair := range utxoSet {
for i, pair := range utxoSet {
err := uis.add(pair.Entry.ScriptPublicKey(), pair.Outpoint, pair.Entry)
if err != nil {
return err
}
const logInterval = 10_000
if i%logInterval == 0 {
log.Debugf("Recovered %d UTXO entries out of %d", i+1, len(utxoSet))
}
}
return uis.commit()