mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-04 13:16:43 +00:00
[NOD-601] Omit nil selected parent in GetBlockVerboseResult (#561)
This commit is contained in:
parent
66a92a243c
commit
cf37f733ef
@ -1575,6 +1575,9 @@ func (dag *BlockDAG) SelectedParentHash(blockHash *daghash.Hash) (*daghash.Hash,
|
||||
|
||||
}
|
||||
|
||||
if node.selectedParent == nil {
|
||||
return nil, nil
|
||||
}
|
||||
return node.selectedParent.hash, nil
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ type GetBlockVerboseResult struct {
|
||||
Bits string `json:"bits"`
|
||||
Difficulty float64 `json:"difficulty"`
|
||||
ParentHashes []string `json:"parentHashes"`
|
||||
SelectedParentHash string `json:"selectedParentHash"`
|
||||
SelectedParentHash string `json:"selectedParentHash,omitempty"`
|
||||
NextHashes []string `json:"nextHashes,omitempty"`
|
||||
}
|
||||
|
||||
|
@ -245,6 +245,10 @@ func buildGetBlockVerboseResult(s *Server, block *util.Block, isVerboseTx bool)
|
||||
context := "Could not get block selected parent"
|
||||
return nil, internalRPCError(err.Error(), context)
|
||||
}
|
||||
selectedParentHashStr := ""
|
||||
if selectedParentHash != nil {
|
||||
selectedParentHashStr = selectedParentHash.String()
|
||||
}
|
||||
|
||||
isChainBlock := s.cfg.DAG.IsInSelectedParentChain(hash)
|
||||
|
||||
@ -256,7 +260,7 @@ func buildGetBlockVerboseResult(s *Server, block *util.Block, isVerboseTx bool)
|
||||
AcceptedIDMerkleRoot: blockHeader.AcceptedIDMerkleRoot.String(),
|
||||
UTXOCommitment: blockHeader.UTXOCommitment.String(),
|
||||
ParentHashes: daghash.Strings(blockHeader.ParentHashes),
|
||||
SelectedParentHash: selectedParentHash.String(),
|
||||
SelectedParentHash: selectedParentHashStr,
|
||||
Nonce: blockHeader.Nonce,
|
||||
Time: blockHeader.Timestamp.Unix(),
|
||||
Confirmations: blockConfirmations,
|
||||
|
Loading…
x
Reference in New Issue
Block a user