From cc8464ce805279735f637ac710b25e2fb264f9aa Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 22 May 2014 17:56:33 +0200 Subject: Transaction querying --- ethchain/block.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'ethchain/block.go') diff --git a/ethchain/block.go b/ethchain/block.go index c846516f4..73e29f878 100644 --- a/ethchain/block.go +++ b/ethchain/block.go @@ -1,6 +1,7 @@ package ethchain import ( + "bytes" "fmt" "github.com/ethereum/eth-go/ethutil" "math/big" @@ -161,6 +162,16 @@ func (block *Block) BlockInfo() BlockInfo { return bi } +func (self *Block) GetTransaction(hash []byte) *Transaction { + for _, receipt := range self.receipts { + if bytes.Compare(receipt.Tx.Hash(), hash) == 0 { + return receipt.Tx + } + } + + return nil +} + // Sync the block's state and contract respectively func (block *Block) Sync() { block.state.Sync() -- cgit v1.2.3