Store and retrieve tx context metadata #608

Improving this in the future will allow for cleaning up a bit of legacy
code.
This commit is contained in:
Taylor Gerring
2015-03-31 22:40:12 +02:00
parent 7e3875b527
commit 40ea466200
3 changed files with 51 additions and 8 deletions

View File

@ -185,12 +185,29 @@ func (self *XEth) EthBlockByHash(strHash string) *types.Block {
return block
}
func (self *XEth) EthTransactionByHash(hash string) *types.Transaction {
func (self *XEth) EthTransactionByHash(hash string) (tx *types.Transaction, blhash common.Hash, blnum *big.Int, txi uint64) {
data, _ := self.backend.ExtraDb().Get(common.FromHex(hash))
if len(data) != 0 {
return types.NewTransactionFromBytes(data)
tx = types.NewTransactionFromBytes(data)
}
return nil
// blockhash
data, _ = self.backend.ExtraDb().Get(append(common.FromHex(hash), 0x0001))
if len(data) != 0 {
blhash = common.BytesToHash(data)
}
// blocknum
data, _ = self.backend.ExtraDb().Get(append(common.FromHex(hash), 0x0002))
if len(data) != 0 {
blnum = common.Bytes2Big(data)
}
// txindex
data, _ = self.backend.ExtraDb().Get(append(common.FromHex(hash), 0x0003))
if len(data) != 0 {
txi = common.BytesToNumber(data)
}
return
}
func (self *XEth) BlockByNumber(num int64) *Block {