aboutsummaryrefslogtreecommitdiffstats
path: root/ethpub
diff options
context:
space:
mode:
authorMaran <maran.hidskes@gmail.com>2014-05-05 20:15:58 +0800
committerMaran <maran.hidskes@gmail.com>2014-05-05 20:15:58 +0800
commitb98cc2fb4e296c7a9efe50293cc43d6f9ef6f23d (patch)
treea6fae0f95e063801dcb359f2ce4d083a42d04f70 /ethpub
parentfde3e01f80420c367139a9fe647c618b0223842d (diff)
downloadgo-tangerine-b98cc2fb4e296c7a9efe50293cc43d6f9ef6f23d.tar
go-tangerine-b98cc2fb4e296c7a9efe50293cc43d6f9ef6f23d.tar.gz
go-tangerine-b98cc2fb4e296c7a9efe50293cc43d6f9ef6f23d.tar.bz2
go-tangerine-b98cc2fb4e296c7a9efe50293cc43d6f9ef6f23d.tar.lz
go-tangerine-b98cc2fb4e296c7a9efe50293cc43d6f9ef6f23d.tar.xz
go-tangerine-b98cc2fb4e296c7a9efe50293cc43d6f9ef6f23d.tar.zst
go-tangerine-b98cc2fb4e296c7a9efe50293cc43d6f9ef6f23d.zip
Fixed GetBlock when no block can be found
Diffstat (limited to 'ethpub')
-rw-r--r--ethpub/pub.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/ethpub/pub.go b/ethpub/pub.go
index 5dc08160f..64109dbfa 100644
--- a/ethpub/pub.go
+++ b/ethpub/pub.go
@@ -24,7 +24,15 @@ func (lib *PEthereum) GetBlock(hexHash string) *PBlock {
block := lib.blockChain.GetBlock(hash)
- return &PBlock{Number: int(block.BlockInfo().Number), Hash: ethutil.Hex(block.Hash())}
+ var blockInfo *PBlock
+
+ if block != nil {
+ blockInfo = &PBlock{Number: int(block.BlockInfo().Number), Hash: ethutil.Hex(block.Hash())}
+ } else {
+ blockInfo = &PBlock{Number: -1, Hash: ""}
+ }
+
+ return blockInfo
}
func (lib *PEthereum) GetKey() *PKey {