aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-08-20 22:40:19 +0800
committerobscuren <geffobscura@gmail.com>2014-08-20 22:40:19 +0800
commit79c64f6bca4fcfb257496be22c64f4b2faed7050 (patch)
treea8a0b76aa9e1da9b4d58c498985c8f45eea9a9f6
parent89c442cadbf995f09259b6a30a6d51989bd3d777 (diff)
downloadgo-tangerine-79c64f6bca4fcfb257496be22c64f4b2faed7050.tar
go-tangerine-79c64f6bca4fcfb257496be22c64f4b2faed7050.tar.gz
go-tangerine-79c64f6bca4fcfb257496be22c64f4b2faed7050.tar.bz2
go-tangerine-79c64f6bca4fcfb257496be22c64f4b2faed7050.tar.lz
go-tangerine-79c64f6bca4fcfb257496be22c64f4b2faed7050.tar.xz
go-tangerine-79c64f6bca4fcfb257496be22c64f4b2faed7050.tar.zst
go-tangerine-79c64f6bca4fcfb257496be22c64f4b2faed7050.zip
Added block by hash or number
-rw-r--r--ethpipe/js_pipe.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/ethpipe/js_pipe.go b/ethpipe/js_pipe.go
index 51de4ddbe..8f08a7c5f 100644
--- a/ethpipe/js_pipe.go
+++ b/ethpipe/js_pipe.go
@@ -28,7 +28,7 @@ func (self *JSPipe) BlockByHash(strHash string) *JSBlock {
return NewJSBlock(block)
}
-func (self *JSPipe) GetBlockByNumber(num int32) *JSBlock {
+func (self *JSPipe) BlockByNumber(num int32) *JSBlock {
if num == -1 {
return NewJSBlock(self.obj.BlockChain().CurrentBlock)
}
@@ -36,6 +36,18 @@ func (self *JSPipe) GetBlockByNumber(num int32) *JSBlock {
return NewJSBlock(self.obj.BlockChain().GetBlockByNumber(uint64(num)))
}
+func (self *JSPipe) Block(v interface{}) *JSBlock {
+ if n, ok := v.(int32); ok {
+ return self.BlockByNumber(n)
+ } else if str, ok := v.(string); ok {
+ return self.BlockByHash(str)
+ } else if f, ok := v.(float64); ok { // Don't ask ...
+ return self.BlockByNumber(int32(f))
+ }
+
+ return nil
+}
+
func (self *JSPipe) Key() *JSKey {
return NewJSKey(self.obj.KeyManager().KeyPair())
}