diff options
author | obscuren <geffobscura@gmail.com> | 2015-02-18 20:14:21 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-02-18 20:14:21 +0800 |
commit | 655e94259765b02454df93205a30a271103de5a0 (patch) | |
tree | 818cd1e9156dda16d78257b2ad656edeb0058759 /core/types | |
parent | be90ad89a89502ef3d2c0375d267b667618f5e7c (diff) | |
download | go-tangerine-655e94259765b02454df93205a30a271103de5a0.tar go-tangerine-655e94259765b02454df93205a30a271103de5a0.tar.gz go-tangerine-655e94259765b02454df93205a30a271103de5a0.tar.bz2 go-tangerine-655e94259765b02454df93205a30a271103de5a0.tar.lz go-tangerine-655e94259765b02454df93205a30a271103de5a0.tar.xz go-tangerine-655e94259765b02454df93205a30a271103de5a0.tar.zst go-tangerine-655e94259765b02454df93205a30a271103de5a0.zip |
Added GetBlock GetUncle with OOB guard
Diffstat (limited to 'core/types')
-rw-r--r-- | core/types/block.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/core/types/block.go b/core/types/block.go index fa28f5cc7..d57de1311 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -185,6 +185,18 @@ func (self *Block) GasUsed() *big.Int { return self.header.GasUsed } func (self *Block) Root() []byte { return self.header.Root } func (self *Block) SetRoot(root []byte) { self.header.Root = root } func (self *Block) Size() ethutil.StorageSize { return ethutil.StorageSize(len(ethutil.Encode(self))) } +func (self *Block) GetTransaction(i int) *Transaction { + if len(self.transactions) > i { + return self.transactions[i] + } + return nil +} +func (self *Block) GetUncle(i int) *Header { + if len(self.uncles) > i { + return self.uncles[i] + } + return nil +} // Implement pow.Block func (self *Block) Difficulty() *big.Int { return self.header.Difficulty } |