Add blueScore to RPC GetBlock, and add more INFO logs (#1103)

* Add BlueScore to RPC command GetBlock

* Add info logs when getting new blocks from the p2p
This commit is contained in:
Elichai Turkel 2020-11-18 11:19:12 +02:00 committed by GitHub
parent 8500acd86b
commit 3f92ddd827
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 1 deletions

View File

@ -58,6 +58,7 @@ type BlockVerboseData struct {
Difficulty float64
ParentHashes []string
SelectedParentHash string
BlueScore uint64
}
// TransactionVerboseData holds verbose data about a transaction

View File

@ -13,6 +13,8 @@ func (f *FlowContext) AddOrphan(orphanBlock *externalapi.DomainBlock) {
orphanHash := consensusserialization.BlockHash(orphanBlock)
f.orphans[*orphanHash] = orphanBlock
log.Infof("Received a block with missing parents, adding to orphan pool: %s", orphanHash)
}
// UnorphanBlocks removes the block from the orphan set, and remove all of the blocks that are not orphans anymore.

View File

@ -249,6 +249,8 @@ func (flow *handleRelayInvsFlow) processAndRelayBlock(requestQueue *hashesQueueS
return err
}
log.Infof("Accepted block %s via relay", blockHash)
err = flow.StartIBDIfRequired()
if err != nil {
return err

View File

@ -3,6 +3,7 @@ package rpccontext
import (
"encoding/hex"
"fmt"
"github.com/kaspanet/kaspad/domain/consensus/utils/blocks"
"math/big"
"strconv"
@ -25,6 +26,11 @@ func (ctx *Context) BuildBlockVerboseData(block *externalapi.DomainBlock, includ
hash := consensusserialization.BlockHash(block)
blockHeader := block.Header
blueScore, err := blocks.ExtractBlueScore(block)
if err != nil {
return nil, err
}
result := &appmessage.BlockVerboseData{
Hash: hash.String(),
Version: blockHeader.Version,
@ -37,6 +43,7 @@ func (ctx *Context) BuildBlockVerboseData(block *externalapi.DomainBlock, includ
Time: blockHeader.TimeInMilliseconds,
Bits: strconv.FormatInt(int64(blockHeader.Bits), 16),
Difficulty: ctx.GetDifficultyRatio(blockHeader.Bits, ctx.Config.ActiveNetParams),
BlueScore: blueScore,
}
txIDs := make([]string, len(block.Transactions))

View File

@ -21,7 +21,7 @@ func HandleSubmitBlock(context *rpccontext.Context, _ *router.Router, request ap
return errorMessage, nil
}
log.Infof("Accepted domainBlock %s via submitBlock", consensusserialization.BlockHash(domainBlock))
log.Infof("Accepted block %s via submitBlock", consensusserialization.BlockHash(domainBlock))
response := appmessage.NewSubmitBlockResponseMessage()
return response, nil