diff options
Diffstat (limited to 'xeth/xeth.go')
-rw-r--r-- | xeth/xeth.go | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/xeth/xeth.go b/xeth/xeth.go index 7de3e31be..3ec3f7dd4 100644 --- a/xeth/xeth.go +++ b/xeth/xeth.go @@ -66,12 +66,16 @@ type XEth struct { // regmut sync.Mutex // register map[string][]*interface{} // TODO improve return type - solcPath string - solc *compiler.Solidity - agent *miner.RemoteAgent } +func NewTest(eth *eth.Ethereum, frontend Frontend) *XEth { + return &XEth{ + backend: eth, + frontend: frontend, + } +} + // New creates an XEth that uses the given frontend. // If a nil Frontend is provided, a default frontend which // confirms all transactions will be used. @@ -350,6 +354,24 @@ func (self *XEth) CurrentBlock() *types.Block { return self.backend.ChainManager().CurrentBlock() } +func (self *XEth) GetBlockReceipts(bhash common.Hash) (receipts types.Receipts, err error) { + return self.backend.BlockProcessor().GetBlockReceipts(bhash) +} + +func (self *XEth) GetTxReceipt(txhash common.Hash) (receipt *types.Receipt, err error) { + _, bhash, _, txi := self.EthTransactionByHash(common.ToHex(txhash[:])) + var receipts types.Receipts + receipts, err = self.backend.BlockProcessor().GetBlockReceipts(bhash) + if err == nil { + if txi < uint64(len(receipts)) { + receipt = receipts[txi] + } else { + err = fmt.Errorf("Invalid tx index") + } + } + return +} + func (self *XEth) GasLimit() *big.Int { return self.backend.ChainManager().GasLimit() } @@ -379,17 +401,12 @@ func (self *XEth) Accounts() []string { // accessor for solidity compiler. // memoized if available, retried on-demand if not func (self *XEth) Solc() (*compiler.Solidity, error) { - var err error - if self.solc == nil { - self.solc, err = compiler.New(self.solcPath) - } - return self.solc, err + return self.backend.Solc() } // set in js console via admin interface or wrapper from cli flags func (self *XEth) SetSolc(solcPath string) (*compiler.Solidity, error) { - self.solcPath = solcPath - self.solc = nil + self.backend.SetSolc(solcPath) return self.Solc() } |