aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-04-01 21:44:09 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-04-01 21:44:09 +0800
commitac03ff6f055ef2bd9404a30a0c257fdd2722eafe (patch)
tree6cfcc4b9fb5a3371916df813974e767ea22ce88e
parent6e8ff578f18473d7c4fe013a88d2bece1ecf65d1 (diff)
downloaddexon-ac03ff6f055ef2bd9404a30a0c257fdd2722eafe.tar
dexon-ac03ff6f055ef2bd9404a30a0c257fdd2722eafe.tar.gz
dexon-ac03ff6f055ef2bd9404a30a0c257fdd2722eafe.tar.bz2
dexon-ac03ff6f055ef2bd9404a30a0c257fdd2722eafe.tar.lz
dexon-ac03ff6f055ef2bd9404a30a0c257fdd2722eafe.tar.xz
dexon-ac03ff6f055ef2bd9404a30a0c257fdd2722eafe.tar.zst
dexon-ac03ff6f055ef2bd9404a30a0c257fdd2722eafe.zip
Fix block size output #613
-rw-r--r--common/size.go4
-rw-r--r--rpc/responses.go2
-rw-r--r--rpc/responses_test.go3
3 files changed, 7 insertions, 2 deletions
diff --git a/common/size.go b/common/size.go
index b5c0b0b3f..0d9dbf558 100644
--- a/common/size.go
+++ b/common/size.go
@@ -17,6 +17,10 @@ func (self StorageSize) String() string {
}
}
+func (self StorageSize) Int64() int64 {
+ return int64(self)
+}
+
// The different number of units
var (
Douglas = BigPow(10, 42)
diff --git a/rpc/responses.go b/rpc/responses.go
index 0f67299fc..41776a0be 100644
--- a/rpc/responses.go
+++ b/rpc/responses.go
@@ -49,7 +49,7 @@ func NewBlockRes(block *types.Block, fullTx bool) *BlockRes {
res.Miner = newHexData(block.Header().Coinbase)
res.Difficulty = newHexNum(block.Difficulty())
res.TotalDifficulty = newHexNum(block.Td)
- res.Size = newHexNum(block.Size())
+ res.Size = newHexNum(block.Size().Int64())
res.ExtraData = newHexData(block.Header().Extra)
res.GasLimit = newHexNum(block.GasLimit())
// res.MinGasPrice =
diff --git a/rpc/responses_test.go b/rpc/responses_test.go
index 949e1794b..704a38186 100644
--- a/rpc/responses_test.go
+++ b/rpc/responses_test.go
@@ -18,6 +18,7 @@ const (
reAddress = `"0x[0-9a-f]{40}"` // 20 bytes
reAddressOpt = `"0x[0-9a-f]{40}"|null` // 20 bytes or null
reNum = `"0x([1-9a-f][0-9a-f]{0,15})|0"` // must not have left-padded zeros
+ reNumNonZero = `"0x([1-9a-f][0-9a-f]{0,15})"` // non-zero required must not have left-padded zeros
reNumOpt = `"0x([1-9a-f][0-9a-f]{0,15})|0"|null` // must not have left-padded zeros or null
reData = `"0x[0-9a-f]*"` // can be "empty"
)
@@ -42,7 +43,7 @@ func TestNewBlockRes(t *testing.T) {
"miner": reAddress,
"difficulty": `"0x1"`,
"totalDifficulty": reNum,
- "size": reNum,
+ "size": reNumNonZero,
"extraData": reData,
"gasLimit": reNum,
// "minGasPrice": "0x",