Added block by hash or number
This commit is contained in:
parent
89c442cadb
commit
79c64f6bca
@ -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())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user