mirror of
https://github.com/LBRYFoundation/lbcd.git
synced 2025-09-01 09:45:14 +00:00
rpc: update getblock response
This commit is contained in:
parent
d884f96553
commit
07d25ba7ce
2 changed files with 9 additions and 4 deletions
|
@ -25,7 +25,7 @@ type GetBlockHeaderVerboseResult struct {
|
||||||
Version int32 `json:"version"`
|
Version int32 `json:"version"`
|
||||||
VersionHex string `json:"versionHex"`
|
VersionHex string `json:"versionHex"`
|
||||||
MerkleRoot string `json:"merkleroot"`
|
MerkleRoot string `json:"merkleroot"`
|
||||||
ClaimTrie string `json:"claimtrie"`
|
ClaimTrie string `json:"claimtrie,omitempty"`
|
||||||
Time int64 `json:"time"`
|
Time int64 `json:"time"`
|
||||||
Nonce uint64 `json:"nonce"`
|
Nonce uint64 `json:"nonce"`
|
||||||
Bits string `json:"bits"`
|
Bits string `json:"bits"`
|
||||||
|
@ -82,14 +82,14 @@ type GetBlockVerboseResult struct {
|
||||||
Version int32 `json:"version"`
|
Version int32 `json:"version"`
|
||||||
VersionHex string `json:"versionHex"`
|
VersionHex string `json:"versionHex"`
|
||||||
MerkleRoot string `json:"merkleroot"`
|
MerkleRoot string `json:"merkleroot"`
|
||||||
ClaimTrie string `json:"claimTrie"`
|
ClaimTrie string `json:"claimTrie,omitempty"`
|
||||||
Tx []string `json:"tx,omitempty"`
|
Tx []string `json:"tx,omitempty"`
|
||||||
RawTx []TxRawResult `json:"rawtx,omitempty"` // Note: this field is always empty when verbose != 2.
|
RawTx []TxRawResult `json:"rawtx,omitempty"` // Note: this field is always empty when verbose != 2.
|
||||||
Time int64 `json:"time"`
|
Time int64 `json:"time"`
|
||||||
Nonce uint32 `json:"nonce"`
|
Nonce uint32 `json:"nonce"`
|
||||||
Bits string `json:"bits"`
|
Bits string `json:"bits"`
|
||||||
Difficulty float64 `json:"difficulty"`
|
Difficulty float64 `json:"difficulty"`
|
||||||
PreviousHash string `json:"previousblockhash"`
|
PreviousHash string `json:"previousblockhash,omitempty"`
|
||||||
NextHash string `json:"nextblockhash,omitempty"`
|
NextHash string `json:"nextblockhash,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1188,12 +1188,16 @@ func handleGetBlock(s *rpcServer, cmd interface{}, closeChan <-chan struct{}) (i
|
||||||
|
|
||||||
params := s.cfg.ChainParams
|
params := s.cfg.ChainParams
|
||||||
blockHeader := &blk.MsgBlock().Header
|
blockHeader := &blk.MsgBlock().Header
|
||||||
|
var prevHashString string
|
||||||
|
if blockHeight > 0 {
|
||||||
|
prevHashString = blockHeader.PrevBlock.String()
|
||||||
|
}
|
||||||
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.MerkleRoot.String(),
|
MerkleRoot: blockHeader.MerkleRoot.String(),
|
||||||
PreviousHash: blockHeader.PrevBlock.String(),
|
PreviousHash: prevHashString,
|
||||||
Nonce: blockHeader.Nonce,
|
Nonce: blockHeader.Nonce,
|
||||||
Time: blockHeader.Timestamp.Unix(),
|
Time: blockHeader.Timestamp.Unix(),
|
||||||
Confirmations: int64(1 + best.Height - blockHeight),
|
Confirmations: int64(1 + best.Height - blockHeight),
|
||||||
|
@ -1204,6 +1208,7 @@ func handleGetBlock(s *rpcServer, cmd interface{}, closeChan <-chan struct{}) (i
|
||||||
Bits: strconv.FormatInt(int64(blockHeader.Bits), 16),
|
Bits: strconv.FormatInt(int64(blockHeader.Bits), 16),
|
||||||
Difficulty: getDifficultyRatio(blockHeader.Bits, params),
|
Difficulty: getDifficultyRatio(blockHeader.Bits, params),
|
||||||
NextHash: nextHashString,
|
NextHash: nextHashString,
|
||||||
|
ClaimTrie: blockHeader.ClaimTrie.String(),
|
||||||
}
|
}
|
||||||
|
|
||||||
if *c.Verbosity == 1 {
|
if *c.Verbosity == 1 {
|
||||||
|
|
Loading…
Add table
Reference in a new issue