From b98cc2fb4e296c7a9efe50293cc43d6f9ef6f23d Mon Sep 17 00:00:00 2001
From: Maran <maran.hidskes@gmail.com>
Date: Mon, 5 May 2014 14:15:58 +0200
Subject: [PATCH] Fixed GetBlock when no block can be found

---
 ethpub/pub.go | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

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 {
-- 
GitLab