mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-10-14 00:59:33 +00:00
[NOD-165] In getBlockVerboseResult and getBlockHeaderVerboseResult, renamed merkleRoot to HashMerkleRoot and added idMerkleRoot and acceptedIdMerkleRoot. (#294)
This commit is contained in:
parent
08d94c7a47
commit
dfd12cdaac
@ -10,39 +10,43 @@ import "encoding/json"
|
|||||||
// the verbose flag is set. When the verbose flag is not set, getblockheader
|
// the verbose flag is set. When the verbose flag is not set, getblockheader
|
||||||
// returns a hex-encoded string.
|
// returns a hex-encoded string.
|
||||||
type GetBlockHeaderVerboseResult struct {
|
type GetBlockHeaderVerboseResult struct {
|
||||||
Hash string `json:"hash"`
|
Hash string `json:"hash"`
|
||||||
Confirmations uint64 `json:"confirmations"`
|
Confirmations uint64 `json:"confirmations"`
|
||||||
Height uint64 `json:"height"`
|
Height uint64 `json:"height"`
|
||||||
Version int32 `json:"version"`
|
Version int32 `json:"version"`
|
||||||
VersionHex string `json:"versionHex"`
|
VersionHex string `json:"versionHex"`
|
||||||
MerkleRoot string `json:"merkleRoot"`
|
HashMerkleRoot string `json:"hashMerkleRoot"`
|
||||||
Time int64 `json:"time"`
|
IDMerkleRoot string `json:"idMerkleRoot"`
|
||||||
Nonce uint64 `json:"nonce"`
|
AcceptedIDMerkleRoot string `json:"acceptedIdMerkleRoot"`
|
||||||
Bits string `json:"bits"`
|
Time int64 `json:"time"`
|
||||||
Difficulty float64 `json:"difficulty"`
|
Nonce uint64 `json:"nonce"`
|
||||||
ParentHashes []string `json:"parentHashes,omitempty"`
|
Bits string `json:"bits"`
|
||||||
NextHashes []string `json:"nextHashes,omitempty"`
|
Difficulty float64 `json:"difficulty"`
|
||||||
|
ParentHashes []string `json:"parentHashes,omitempty"`
|
||||||
|
NextHashes []string `json:"nextHashes,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetBlockVerboseResult models the data from the getblock command when the
|
// GetBlockVerboseResult models the data from the getblock command when the
|
||||||
// verbose flag is set. When the verbose flag is not set, getblock returns a
|
// verbose flag is set. When the verbose flag is not set, getblock returns a
|
||||||
// hex-encoded string.
|
// hex-encoded string.
|
||||||
type GetBlockVerboseResult struct {
|
type GetBlockVerboseResult struct {
|
||||||
Hash string `json:"hash"`
|
Hash string `json:"hash"`
|
||||||
Confirmations uint64 `json:"confirmations"`
|
Confirmations uint64 `json:"confirmations"`
|
||||||
Size int32 `json:"size"`
|
Size int32 `json:"size"`
|
||||||
Height uint64 `json:"height"`
|
Height uint64 `json:"height"`
|
||||||
Version int32 `json:"version"`
|
Version int32 `json:"version"`
|
||||||
VersionHex string `json:"versionHex"`
|
VersionHex string `json:"versionHex"`
|
||||||
MerkleRoot string `json:"merkleRoot"`
|
HashMerkleRoot string `json:"hashMerkleRoot"`
|
||||||
Tx []string `json:"tx,omitempty"`
|
IDMerkleRoot string `json:"idMerkleRoot"`
|
||||||
RawTx []TxRawResult `json:"rawRx,omitempty"`
|
AcceptedIDMerkleRoot string `json:"acceptedIdMerkleRoot"`
|
||||||
Time int64 `json:"time"`
|
Tx []string `json:"tx,omitempty"`
|
||||||
Nonce uint64 `json:"nonce"`
|
RawTx []TxRawResult `json:"rawRx,omitempty"`
|
||||||
Bits string `json:"bits"`
|
Time int64 `json:"time"`
|
||||||
Difficulty float64 `json:"difficulty"`
|
Nonce uint64 `json:"nonce"`
|
||||||
ParentHashes []string `json:"parentHashes"`
|
Bits string `json:"bits"`
|
||||||
NextHashes []string `json:"nextHashes,omitempty"`
|
Difficulty float64 `json:"difficulty"`
|
||||||
|
ParentHashes []string `json:"parentHashes"`
|
||||||
|
NextHashes []string `json:"nextHashes,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateMultiSigResult models the data returned from the createmultisig
|
// CreateMultiSigResult models the data returned from the createmultisig
|
||||||
|
@ -1194,19 +1194,21 @@ func handleGetBlock(s *Server, cmd interface{}, closeChan <-chan struct{}) (inte
|
|||||||
params := s.cfg.DAGParams
|
params := s.cfg.DAGParams
|
||||||
blockHeader := &blk.MsgBlock().Header
|
blockHeader := &blk.MsgBlock().Header
|
||||||
blockReply := btcjson.GetBlockVerboseResult{
|
blockReply := btcjson.GetBlockVerboseResult{
|
||||||
Hash: c.Hash,
|
Hash: c.Hash,
|
||||||
Version: blockHeader.Version,
|
Version: blockHeader.Version,
|
||||||
VersionHex: fmt.Sprintf("%08x", blockHeader.Version),
|
VersionHex: fmt.Sprintf("%08x", blockHeader.Version),
|
||||||
MerkleRoot: blockHeader.HashMerkleRoot.String(),
|
HashMerkleRoot: blockHeader.HashMerkleRoot.String(),
|
||||||
ParentHashes: daghash.Strings(blockHeader.ParentHashes),
|
IDMerkleRoot: blockHeader.IDMerkleRoot.String(),
|
||||||
Nonce: blockHeader.Nonce,
|
AcceptedIDMerkleRoot: blockHeader.AcceptedIDMerkleRoot.String(),
|
||||||
Time: blockHeader.Timestamp.Unix(),
|
ParentHashes: daghash.Strings(blockHeader.ParentHashes),
|
||||||
Confirmations: uint64(1 + s.cfg.DAG.Height() - blockHeight), //TODO: (Ori) This is probably wrong. Done only for compilation
|
Nonce: blockHeader.Nonce,
|
||||||
Height: blockHeight,
|
Time: blockHeader.Timestamp.Unix(),
|
||||||
Size: int32(len(blkBytes)),
|
Confirmations: uint64(1 + s.cfg.DAG.Height() - blockHeight), //TODO: (Ori) This is probably wrong. Done only for compilation
|
||||||
Bits: strconv.FormatInt(int64(blockHeader.Bits), 16),
|
Height: blockHeight,
|
||||||
Difficulty: getDifficultyRatio(blockHeader.Bits, params),
|
Size: int32(len(blkBytes)),
|
||||||
NextHashes: nextHashStrings,
|
Bits: strconv.FormatInt(int64(blockHeader.Bits), 16),
|
||||||
|
Difficulty: getDifficultyRatio(blockHeader.Bits, params),
|
||||||
|
NextHashes: nextHashStrings,
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.VerboseTx == nil || !*c.VerboseTx {
|
if c.VerboseTx == nil || !*c.VerboseTx {
|
||||||
@ -1393,18 +1395,20 @@ func handleGetBlockHeader(s *Server, cmd interface{}, closeChan <-chan struct{})
|
|||||||
|
|
||||||
params := s.cfg.DAGParams
|
params := s.cfg.DAGParams
|
||||||
blockHeaderReply := btcjson.GetBlockHeaderVerboseResult{
|
blockHeaderReply := btcjson.GetBlockHeaderVerboseResult{
|
||||||
Hash: c.Hash,
|
Hash: c.Hash,
|
||||||
Confirmations: uint64(1 + s.cfg.DAG.Height() - blockHeight), //TODO: (Ori) This is probably wrong. Done only for compilation
|
Confirmations: uint64(1 + s.cfg.DAG.Height() - blockHeight), //TODO: (Ori) This is probably wrong. Done only for compilation
|
||||||
Height: blockHeight,
|
Height: blockHeight,
|
||||||
Version: blockHeader.Version,
|
Version: blockHeader.Version,
|
||||||
VersionHex: fmt.Sprintf("%08x", blockHeader.Version),
|
VersionHex: fmt.Sprintf("%08x", blockHeader.Version),
|
||||||
MerkleRoot: blockHeader.HashMerkleRoot.String(),
|
HashMerkleRoot: blockHeader.HashMerkleRoot.String(),
|
||||||
NextHashes: nextHashStrings,
|
IDMerkleRoot: blockHeader.IDMerkleRoot.String(),
|
||||||
ParentHashes: daghash.Strings(blockHeader.ParentHashes),
|
AcceptedIDMerkleRoot: blockHeader.AcceptedIDMerkleRoot.String(),
|
||||||
Nonce: uint64(blockHeader.Nonce),
|
NextHashes: nextHashStrings,
|
||||||
Time: blockHeader.Timestamp.Unix(),
|
ParentHashes: daghash.Strings(blockHeader.ParentHashes),
|
||||||
Bits: strconv.FormatInt(int64(blockHeader.Bits), 16),
|
Nonce: uint64(blockHeader.Nonce),
|
||||||
Difficulty: getDifficultyRatio(blockHeader.Bits, params),
|
Time: blockHeader.Timestamp.Unix(),
|
||||||
|
Bits: strconv.FormatInt(int64(blockHeader.Bits), 16),
|
||||||
|
Difficulty: getDifficultyRatio(blockHeader.Bits, params),
|
||||||
}
|
}
|
||||||
return blockHeaderReply, nil
|
return blockHeaderReply, nil
|
||||||
}
|
}
|
||||||
|
@ -235,21 +235,23 @@ var helpDescsEnUS = map[string]string{
|
|||||||
"searchRawTransactionsResult-size": "The size of the transaction in bytes",
|
"searchRawTransactionsResult-size": "The size of the transaction in bytes",
|
||||||
|
|
||||||
// GetBlockVerboseResult help.
|
// GetBlockVerboseResult help.
|
||||||
"getBlockVerboseResult-hash": "The hash of the block (same as provided)",
|
"getBlockVerboseResult-hash": "The hash of the block (same as provided)",
|
||||||
"getBlockVerboseResult-confirmations": "The number of confirmations",
|
"getBlockVerboseResult-confirmations": "The number of confirmations",
|
||||||
"getBlockVerboseResult-size": "The size of the block",
|
"getBlockVerboseResult-size": "The size of the block",
|
||||||
"getBlockVerboseResult-height": "The height of the block in the block chain",
|
"getBlockVerboseResult-height": "The height of the block in the block chain",
|
||||||
"getBlockVerboseResult-version": "The block version",
|
"getBlockVerboseResult-version": "The block version",
|
||||||
"getBlockVerboseResult-versionHex": "The block version in hexadecimal",
|
"getBlockVerboseResult-versionHex": "The block version in hexadecimal",
|
||||||
"getBlockVerboseResult-merkleRoot": "Root hash of the merkle tree",
|
"getBlockVerboseResult-hashMerkleRoot": "Merkle tree reference to hash of all transactions for the block",
|
||||||
"getBlockVerboseResult-tx": "The transaction hashes (only when verbosetx=false)",
|
"getBlockVerboseResult-idMerkleRoot": "Merkle tree reference to hash of all transactions' IDs for the block",
|
||||||
"getBlockVerboseResult-rawRx": "The transactions as JSON objects (only when verbosetx=true)",
|
"getBlockVerboseResult-acceptedIdMerkleRoot": "Merkle tree reference to hash all transactions accepted form the block blues",
|
||||||
"getBlockVerboseResult-time": "The block time in seconds since 1 Jan 1970 GMT",
|
"getBlockVerboseResult-tx": "The transaction hashes (only when verbosetx=false)",
|
||||||
"getBlockVerboseResult-nonce": "The block nonce",
|
"getBlockVerboseResult-rawRx": "The transactions as JSON objects (only when verbosetx=true)",
|
||||||
"getBlockVerboseResult-bits": "The bits which represent the block difficulty",
|
"getBlockVerboseResult-time": "The block time in seconds since 1 Jan 1970 GMT",
|
||||||
"getBlockVerboseResult-difficulty": "The proof-of-work difficulty as a multiple of the minimum difficulty",
|
"getBlockVerboseResult-nonce": "The block nonce",
|
||||||
"getBlockVerboseResult-parentHashes": "The hashes of the parent blocks",
|
"getBlockVerboseResult-bits": "The bits which represent the block difficulty",
|
||||||
"getBlockVerboseResult-nextHashes": "The hashes of the next blocks (only if there are any)",
|
"getBlockVerboseResult-difficulty": "The proof-of-work difficulty as a multiple of the minimum difficulty",
|
||||||
|
"getBlockVerboseResult-parentHashes": "The hashes of the parent blocks",
|
||||||
|
"getBlockVerboseResult-nextHashes": "The hashes of the next blocks (only if there are any)",
|
||||||
|
|
||||||
// GetBlockCountCmd help.
|
// GetBlockCountCmd help.
|
||||||
"getBlockCount--synopsis": "Returns the number of blocks in the longest block chain.",
|
"getBlockCount--synopsis": "Returns the number of blocks in the longest block chain.",
|
||||||
@ -269,18 +271,20 @@ var helpDescsEnUS = map[string]string{
|
|||||||
"getBlockHeader--result0": "The block header hash",
|
"getBlockHeader--result0": "The block header hash",
|
||||||
|
|
||||||
// GetBlockHeaderVerboseResult help.
|
// GetBlockHeaderVerboseResult help.
|
||||||
"getBlockHeaderVerboseResult-hash": "The hash of the block (same as provided)",
|
"getBlockHeaderVerboseResult-hash": "The hash of the block (same as provided)",
|
||||||
"getBlockHeaderVerboseResult-confirmations": "The number of confirmations",
|
"getBlockHeaderVerboseResult-confirmations": "The number of confirmations",
|
||||||
"getBlockHeaderVerboseResult-height": "The height of the block in the block chain",
|
"getBlockHeaderVerboseResult-height": "The height of the block in the block chain",
|
||||||
"getBlockHeaderVerboseResult-version": "The block version",
|
"getBlockHeaderVerboseResult-version": "The block version",
|
||||||
"getBlockHeaderVerboseResult-versionHex": "The block version in hexadecimal",
|
"getBlockHeaderVerboseResult-versionHex": "The block version in hexadecimal",
|
||||||
"getBlockHeaderVerboseResult-merkleRoot": "Root hash of the merkle tree",
|
"getBlockHeaderVerboseResult-hashMerkleRoot": "Merkle tree reference to hash of all transactions for the block",
|
||||||
"getBlockHeaderVerboseResult-time": "The block time in seconds since 1 Jan 1970 GMT",
|
"getBlockHeaderVerboseResult-idMerkleRoot": "Merkle tree reference to hash of all transactions' IDs for the block",
|
||||||
"getBlockHeaderVerboseResult-nonce": "The block nonce",
|
"getBlockHeaderVerboseResult-acceptedIdMerkleRoot": "Merkle tree reference to hash all transactions accepted form the block blues",
|
||||||
"getBlockHeaderVerboseResult-bits": "The bits which represent the block difficulty",
|
"getBlockHeaderVerboseResult-time": "The block time in seconds since 1 Jan 1970 GMT",
|
||||||
"getBlockHeaderVerboseResult-difficulty": "The proof-of-work difficulty as a multiple of the minimum difficulty",
|
"getBlockHeaderVerboseResult-nonce": "The block nonce",
|
||||||
"getBlockHeaderVerboseResult-parentHashes": "The hashes of the parent blocks",
|
"getBlockHeaderVerboseResult-bits": "The bits which represent the block difficulty",
|
||||||
"getBlockHeaderVerboseResult-nextHashes": "The hashes of the next blocks (only if there are any)",
|
"getBlockHeaderVerboseResult-difficulty": "The proof-of-work difficulty as a multiple of the minimum difficulty",
|
||||||
|
"getBlockHeaderVerboseResult-parentHashes": "The hashes of the parent blocks",
|
||||||
|
"getBlockHeaderVerboseResult-nextHashes": "The hashes of the next blocks (only if there are any)",
|
||||||
|
|
||||||
// TemplateRequest help.
|
// TemplateRequest help.
|
||||||
"templateRequest-mode": "This is 'template', 'proposal', or omitted",
|
"templateRequest-mode": "This is 'template', 'proposal', or omitted",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user