mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-10-14 00:59:33 +00:00
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:
parent
8500acd86b
commit
3f92ddd827
@ -58,6 +58,7 @@ type BlockVerboseData struct {
|
|||||||
Difficulty float64
|
Difficulty float64
|
||||||
ParentHashes []string
|
ParentHashes []string
|
||||||
SelectedParentHash string
|
SelectedParentHash string
|
||||||
|
BlueScore uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
// TransactionVerboseData holds verbose data about a transaction
|
// TransactionVerboseData holds verbose data about a transaction
|
||||||
|
@ -13,6 +13,8 @@ func (f *FlowContext) AddOrphan(orphanBlock *externalapi.DomainBlock) {
|
|||||||
|
|
||||||
orphanHash := consensusserialization.BlockHash(orphanBlock)
|
orphanHash := consensusserialization.BlockHash(orphanBlock)
|
||||||
f.orphans[*orphanHash] = 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.
|
// UnorphanBlocks removes the block from the orphan set, and remove all of the blocks that are not orphans anymore.
|
||||||
|
@ -249,6 +249,8 @@ func (flow *handleRelayInvsFlow) processAndRelayBlock(requestQueue *hashesQueueS
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Infof("Accepted block %s via relay", blockHash)
|
||||||
|
|
||||||
err = flow.StartIBDIfRequired()
|
err = flow.StartIBDIfRequired()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -3,6 +3,7 @@ package rpccontext
|
|||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/kaspanet/kaspad/domain/consensus/utils/blocks"
|
||||||
"math/big"
|
"math/big"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
@ -25,6 +26,11 @@ func (ctx *Context) BuildBlockVerboseData(block *externalapi.DomainBlock, includ
|
|||||||
hash := consensusserialization.BlockHash(block)
|
hash := consensusserialization.BlockHash(block)
|
||||||
blockHeader := block.Header
|
blockHeader := block.Header
|
||||||
|
|
||||||
|
blueScore, err := blocks.ExtractBlueScore(block)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
result := &appmessage.BlockVerboseData{
|
result := &appmessage.BlockVerboseData{
|
||||||
Hash: hash.String(),
|
Hash: hash.String(),
|
||||||
Version: blockHeader.Version,
|
Version: blockHeader.Version,
|
||||||
@ -37,6 +43,7 @@ func (ctx *Context) BuildBlockVerboseData(block *externalapi.DomainBlock, includ
|
|||||||
Time: blockHeader.TimeInMilliseconds,
|
Time: blockHeader.TimeInMilliseconds,
|
||||||
Bits: strconv.FormatInt(int64(blockHeader.Bits), 16),
|
Bits: strconv.FormatInt(int64(blockHeader.Bits), 16),
|
||||||
Difficulty: ctx.GetDifficultyRatio(blockHeader.Bits, ctx.Config.ActiveNetParams),
|
Difficulty: ctx.GetDifficultyRatio(blockHeader.Bits, ctx.Config.ActiveNetParams),
|
||||||
|
BlueScore: blueScore,
|
||||||
}
|
}
|
||||||
|
|
||||||
txIDs := make([]string, len(block.Transactions))
|
txIDs := make([]string, len(block.Transactions))
|
||||||
|
@ -21,7 +21,7 @@ func HandleSubmitBlock(context *rpccontext.Context, _ *router.Router, request ap
|
|||||||
return errorMessage, nil
|
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()
|
response := appmessage.NewSubmitBlockResponseMessage()
|
||||||
return response, nil
|
return response, nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user