aboutsummaryrefslogtreecommitdiffstats
path: root/xeth
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-10-22 20:43:21 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-11-19 22:03:32 +0800
commite86e0ecdc8a977db2ff5df60dca3cad8355ace6d (patch)
tree5944b33220457ad5da31b33e15774882c2e6201f /xeth
parentae37a8013d5a348bdb21d4a66d5f462e0baf7cd8 (diff)
downloaddexon-e86e0ecdc8a977db2ff5df60dca3cad8355ace6d.tar
dexon-e86e0ecdc8a977db2ff5df60dca3cad8355ace6d.tar.gz
dexon-e86e0ecdc8a977db2ff5df60dca3cad8355ace6d.tar.bz2
dexon-e86e0ecdc8a977db2ff5df60dca3cad8355ace6d.tar.lz
dexon-e86e0ecdc8a977db2ff5df60dca3cad8355ace6d.tar.xz
dexon-e86e0ecdc8a977db2ff5df60dca3cad8355ace6d.tar.zst
dexon-e86e0ecdc8a977db2ff5df60dca3cad8355ace6d.zip
core, eth, miner, xeth: clean up tx/receipt db accessors
Diffstat (limited to 'xeth')
-rw-r--r--xeth/xeth.go41
1 files changed, 4 insertions, 37 deletions
diff --git a/xeth/xeth.go b/xeth/xeth.go
index 243bef0b8..ae9f1fe47 100644
--- a/xeth/xeth.go
+++ b/xeth/xeth.go
@@ -322,44 +322,11 @@ func (self *XEth) EthBlockByHash(strHash string) *types.Block {
return block
}
-func (self *XEth) EthTransactionByHash(hash string) (tx *types.Transaction, blhash common.Hash, blnum *big.Int, txi uint64) {
- // Due to increasing return params and need to determine if this is from transaction pool or
- // some chain, this probably needs to be refactored for more expressiveness
- data, _ := self.backend.ChainDb().Get(common.FromHex(hash))
- if len(data) != 0 {
- dtx := new(types.Transaction)
- if err := rlp.DecodeBytes(data, dtx); err != nil {
- glog.V(logger.Error).Infoln(err)
- return
- }
- tx = dtx
- } else { // check pending transactions
- tx = self.backend.TxPool().GetTransaction(common.HexToHash(hash))
- }
-
- // meta
- var txExtra struct {
- BlockHash common.Hash
- BlockIndex uint64
- Index uint64
- }
-
- v, dberr := self.backend.ChainDb().Get(append(common.FromHex(hash), 0x0001))
- // TODO check specifically for ErrNotFound
- if dberr != nil {
- return
+func (self *XEth) EthTransactionByHash(hash string) (*types.Transaction, common.Hash, uint64, uint64) {
+ if tx, hash, number, index := core.GetTransaction(self.backend.ChainDb(), common.HexToHash(hash)); tx != nil {
+ return tx, hash, number, index
}
- r := bytes.NewReader(v)
- err := rlp.Decode(r, &txExtra)
- if err == nil {
- blhash = txExtra.BlockHash
- blnum = big.NewInt(int64(txExtra.BlockIndex))
- txi = txExtra.Index
- } else {
- glog.V(logger.Error).Infoln(err)
- }
-
- return
+ return self.backend.TxPool().GetTransaction(common.HexToHash(hash)), common.Hash{}, 0, 0
}
func (self *XEth) BlockByNumber(num int64) *Block {