From 54b5c8273db33ebc2bee762b92fa4a6c24e6ad94 Mon Sep 17 00:00:00 2001 From: Taylor Gerring Date: Mon, 18 May 2015 10:41:56 -0500 Subject: XEth comment clarification --- xeth/xeth.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'xeth') diff --git a/xeth/xeth.go b/xeth/xeth.go index 88cd30afc..2d01bc681 100644 --- a/xeth/xeth.go +++ b/xeth/xeth.go @@ -304,6 +304,8 @@ func (self *XEth) EthBlockByHash(strHash string) *types.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.ExtraDb().Get(common.FromHex(hash)) if len(data) != 0 { tx = types.NewTransactionFromBytes(data) @@ -357,7 +359,7 @@ func (self *XEth) Block(v interface{}) *Block { return self.BlockByNumber(int64(n)) } else if str, ok := v.(string); ok { return self.BlockByHash(str) - } else if f, ok := v.(float64); ok { // Don't ask ... + } else if f, ok := v.(float64); ok { // JSON numbers are represented as float64 return self.BlockByNumber(int64(f)) } @@ -778,7 +780,7 @@ func (self *XEth) PushTx(encodedTx string) (string, error) { } func (self *XEth) Call(fromStr, toStr, valueStr, gasStr, gasPriceStr, dataStr string) (string, string, error) { - statedb := self.State().State().Copy() //self.eth.ChainManager().TransState() + statedb := self.State().State().Copy() var from *state.StateObject if len(fromStr) == 0 { accounts, err := self.backend.AccountManager().Accounts() @@ -869,6 +871,7 @@ func (self *XEth) Transact(fromStr, toStr, nonceStr, valueStr, gasStr, gasPriceS contractCreation bool ) + // 2015-05-18 Is this still needed? // TODO if no_private_key then //if _, exists := p.register[args.From]; exists { // p.register[args.From] = append(p.register[args.From], args) -- cgit v1.2.3 From b7baceefdab01e4594b66500b54e089c91f2727a Mon Sep 17 00:00:00 2001 From: obscuren Date: Mon, 18 May 2015 20:26:41 +0200 Subject: xeth: remove nonce on error. Fixes #1026 --- xeth/xeth.go | 2 ++ 1 file changed, 2 insertions(+) (limited to 'xeth') diff --git a/xeth/xeth.go b/xeth/xeth.go index 88cd30afc..4d9611cbc 100644 --- a/xeth/xeth.go +++ b/xeth/xeth.go @@ -924,9 +924,11 @@ func (self *XEth) Transact(fromStr, toStr, nonceStr, valueStr, gasStr, gasPriceS tx.SetNonce(nonce) if err := self.sign(tx, from, false); err != nil { + state.RemoveNonce(from, tx.Nonce()) return "", err } if err := self.backend.TxPool().Add(tx); err != nil { + state.RemoveNonce(from, tx.Nonce()) return "", err } -- cgit v1.2.3 From 22b694ee1e1044e68c906fbd864797ac2f8a4ab0 Mon Sep 17 00:00:00 2001 From: zelig Date: Wed, 20 May 2015 02:04:52 +0100 Subject: solc now in ethereum, fixes solc path setting; setSolc() didnt work --- xeth/xeth.go | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'xeth') diff --git a/xeth/xeth.go b/xeth/xeth.go index 7de3e31be..81197d381 100644 --- a/xeth/xeth.go +++ b/xeth/xeth.go @@ -66,9 +66,6 @@ type XEth struct { // regmut sync.Mutex // register map[string][]*interface{} // TODO improve return type - solcPath string - solc *compiler.Solidity - agent *miner.RemoteAgent } @@ -379,17 +376,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() } -- cgit v1.2.3 From b0ae84aa0dae65f00492f981bb61887331def2a5 Mon Sep 17 00:00:00 2001 From: zelig Date: Wed, 20 May 2015 04:11:48 +0100 Subject: multiple contract source for solidity compiler: returns contract array if multiple contracts. fixes #1023 --- xeth/xeth.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'xeth') diff --git a/xeth/xeth.go b/xeth/xeth.go index 81197d381..4925fe635 100644 --- a/xeth/xeth.go +++ b/xeth/xeth.go @@ -69,6 +69,13 @@ type XEth struct { 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. -- cgit v1.2.3 From 00ec4132f89527a6e2ae6b1d3842c447cab38cef Mon Sep 17 00:00:00 2001 From: zsfelfoldi Date: Wed, 20 May 2015 06:41:50 +0200 Subject: Storing tx receipts in extraDb --- xeth/xeth.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'xeth') diff --git a/xeth/xeth.go b/xeth/xeth.go index 7de3e31be..3772146de 100644 --- a/xeth/xeth.go +++ b/xeth/xeth.go @@ -350,6 +350,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() } -- cgit v1.2.3 From ff1630834cddb768826cec0e555a645e13c7bc9c Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 21 May 2015 11:36:05 +0200 Subject: xeth: removed `Value` --- xeth/xeth.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'xeth') diff --git a/xeth/xeth.go b/xeth/xeth.go index 3ec3f7dd4..b90e0aa47 100644 --- a/xeth/xeth.go +++ b/xeth/xeth.go @@ -881,7 +881,7 @@ func (self *XEth) Transact(fromStr, toStr, nonceStr, valueStr, gasStr, gasPriceS var ( from = common.HexToAddress(fromStr) to = common.HexToAddress(toStr) - value = common.NewValue(valueStr) + value = common.Big(valueStr) gas = common.Big(gasStr) price = common.Big(gasPriceStr) data []byte @@ -928,9 +928,9 @@ func (self *XEth) Transact(fromStr, toStr, nonceStr, valueStr, gasStr, gasPriceS var tx *types.Transaction if contractCreation { - tx = types.NewContractCreationTx(value.BigInt(), gas, price, data) + tx = types.NewContractCreationTx(value, gas, price, data) } else { - tx = types.NewTransactionMessage(to, value.BigInt(), gas, price, data) + tx = types.NewTransactionMessage(to, value, gas, price, data) } state := self.backend.ChainManager().TxState() -- cgit v1.2.3 From a61e6788db492b292baaa9c9be09eac9334ff56e Mon Sep 17 00:00:00 2001 From: Bas van Kervel Date: Thu, 21 May 2015 15:20:38 +0200 Subject: prefix dapp key/value entries in extradb --- xeth/xeth.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'xeth') diff --git a/xeth/xeth.go b/xeth/xeth.go index b90e0aa47..157fe76c7 100644 --- a/xeth/xeth.go +++ b/xeth/xeth.go @@ -28,6 +28,7 @@ var ( filterTickerTime = 5 * time.Minute defaultGasPrice = big.NewInt(10000000000000) //150000000000 defaultGas = big.NewInt(90000) //500000 + dappStorePre = []byte("dapp-") ) // byte will be inferred @@ -410,13 +411,15 @@ func (self *XEth) SetSolc(solcPath string) (*compiler.Solidity, error) { return self.Solc() } +// store DApp value in extra database func (self *XEth) DbPut(key, val []byte) bool { - self.backend.ExtraDb().Put(key, val) + self.backend.ExtraDb().Put(append(dappStorePre, key...), val) return true } +// retrieve DApp value from extra database func (self *XEth) DbGet(key []byte) ([]byte, error) { - val, err := self.backend.ExtraDb().Get(key) + val, err := self.backend.ExtraDb().Get(append(dappStorePre, key...)) return val, err } -- cgit v1.2.3