Skip to content

Commit ac03ff6

Browse files
committed
Fix block size output bnb-chain#613
1 parent 6e8ff57 commit ac03ff6

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

‎common/size.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ func (self StorageSize) String() string {
1717
}
1818
}
1919

20+
func (self StorageSize) Int64() int64 {
21+
return int64(self)
22+
}
23+
2024
// The different number of units
2125
var (
2226
Douglas = BigPow(10, 42)

‎rpc/responses.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func NewBlockRes(block *types.Block, fullTx bool) *BlockRes {
4949
res.Miner = newHexData(block.Header().Coinbase)
5050
res.Difficulty = newHexNum(block.Difficulty())
5151
res.TotalDifficulty = newHexNum(block.Td)
52-
res.Size = newHexNum(block.Size())
52+
res.Size = newHexNum(block.Size().Int64())
5353
res.ExtraData = newHexData(block.Header().Extra)
5454
res.GasLimit = newHexNum(block.GasLimit())
5555
// res.MinGasPrice =

‎rpc/responses_test.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const (
1818
reAddress = `"0x[0-9a-f]{40}"` // 20 bytes
1919
reAddressOpt = `"0x[0-9a-f]{40}"|null` // 20 bytes or null
2020
reNum = `"0x([1-9a-f][0-9a-f]{0,15})|0"` // must not have left-padded zeros
21+
reNumNonZero = `"0x([1-9a-f][0-9a-f]{0,15})"` // non-zero required must not have left-padded zeros
2122
reNumOpt = `"0x([1-9a-f][0-9a-f]{0,15})|0"|null` // must not have left-padded zeros or null
2223
reData = `"0x[0-9a-f]*"` // can be "empty"
2324
)
@@ -42,7 +43,7 @@ func TestNewBlockRes(t *testing.T) {
4243
"miner": reAddress,
4344
"difficulty": `"0x1"`,
4445
"totalDifficulty": reNum,
45-
"size": reNum,
46+
"size": reNumNonZero,
4647
"extraData": reData,
4748
"gasLimit": reNum,
4849
// "minGasPrice": "0x",

0 commit comments

Comments
 (0)