Log only tips length, and inspect ReachabilityData error instead of calling HasReachabilityData (#1321)

* Print the amount of tips instead of the tips themselves

* Inspect ReachabilityData error instead of calling HasReachabilityData
This commit is contained in:
Elichai Turkel 2020-12-30 13:02:34 +02:00 committed by GitHub
parent d917a1fc1e
commit bd89ca2125
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 17 deletions

View File

@ -53,7 +53,7 @@ func (csm *consensusStateManager) AddBlock(blockHash *externalapi.DomainHash) (*
if err != nil {
return nil, err
}
log.Debugf("After adding %s, the new tips are %s", blockHash, newTips)
log.Debugf("After adding %s, the amount of new tips are %d", blockHash, len(newTips))
log.Debugf("Updating the virtual with the new tips")
selectedParentChainChanges, err := csm.updateVirtual(blockHash, newTips)
@ -99,10 +99,9 @@ func (csm *consensusStateManager) addTip(newTipHash *externalapi.DomainHash) (ne
if err != nil {
return nil, err
}
log.Debugf("The new tips are: %s", newTips)
csm.consensusStateStore.StageTips(newTips)
log.Debugf("Staged the new tips %s", newTips)
log.Debugf("Staged the new tips, len: %d", len(newTips))
return newTips, nil
}

View File

@ -9,8 +9,8 @@ import (
)
func (csm *consensusStateManager) pickVirtualParents(tips []*externalapi.DomainHash) ([]*externalapi.DomainHash, error) {
log.Debugf("pickVirtualParents start for tips: %s", tips)
defer log.Debugf("pickVirtualParents end for tips: %s", tips)
log.Debugf("pickVirtualParents start for tips len: %d", len(tips))
defer log.Debugf("pickVirtualParents end for tips len: %d", len(tips))
log.Debugf("Pushing all tips into a DownHeap")
candidatesHeap := csm.dagTraversalManager.NewDownHeap()

View File

@ -21,7 +21,7 @@ func (csm *consensusStateManager) updateVirtual(newBlockHash *externalapi.Domain
oldVirtualSelectedParent = oldVirtualGHOSTDAGData.SelectedParent()
}
log.Debugf("Picking virtual parents from the tips: %s", tips)
log.Debugf("Picking virtual parents from tips len: %d", len(tips))
virtualParents, err := csm.pickVirtualParents(tips)
if err != nil {
return nil, err

View File

@ -4,25 +4,21 @@ import (
"github.com/kaspanet/kaspad/domain/consensus/model"
"github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
"github.com/kaspanet/kaspad/domain/consensus/utils/reachabilitydata"
"github.com/kaspanet/kaspad/infrastructure/db/database"
"github.com/pkg/errors"
)
func (rt *reachabilityManager) reachabilityDataForInsertion(
blockHash *externalapi.DomainHash) (model.MutableReachabilityData, error) {
hasData, err := rt.reachabilityDataStore.HasReachabilityData(rt.databaseContext, blockHash)
if err != nil {
return nil, err
data, err := rt.reachabilityDataStore.ReachabilityData(rt.databaseContext, blockHash)
if err == nil {
return data.CloneMutable(), nil
}
if !hasData {
if errors.Is(err, database.ErrNotFound) {
return reachabilitydata.EmptyReachabilityData(), nil
}
data, err := rt.reachabilityDataStore.ReachabilityData(rt.databaseContext, blockHash)
if err != nil {
return nil, err
}
return data.CloneMutable(), nil
return nil, err
}
func (rt *reachabilityManager) futureCoveringSet(blockHash *externalapi.DomainHash) (model.FutureCoveringTreeNodeSet, error) {