diff options
author | Gav Wood <i@gavwood.com> | 2015-03-30 01:13:39 +0800 |
---|---|---|
committer | Gav Wood <i@gavwood.com> | 2015-03-30 01:13:39 +0800 |
commit | 5e28d981c729a929a37ba761e86a47de08ce9456 (patch) | |
tree | 3f9bf122e30a6b5e7d156842b7f1b9117ad7f35b | |
parent | c188e94273f9f9be27b4bfd67e44800f0504eb6a (diff) | |
download | dexon-solidity-5e28d981c729a929a37ba761e86a47de08ce9456.tar.gz dexon-solidity-5e28d981c729a929a37ba761e86a47de08ce9456.tar.zst dexon-solidity-5e28d981c729a929a37ba761e86a47de08ce9456.zip |
Refactored much of transaction queue for tidiness and optimisation.
-rw-r--r-- | blockchain.cpp | 21 | ||||
-rw-r--r-- | checkRandomStateTest.cpp | 3 | ||||
-rw-r--r-- | createRandomStateTest.cpp | 3 | ||||
-rw-r--r-- | solidityExecutionFramework.h | 3 | ||||
-rw-r--r-- | state.cpp | 3 | ||||
-rw-r--r-- | stateOriginal.cpp | 10 |
6 files changed, 18 insertions, 25 deletions
diff --git a/blockchain.cpp b/blockchain.cpp index 50ca22c5..988859fe 100644 --- a/blockchain.cpp +++ b/blockchain.cpp @@ -182,18 +182,17 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) Transactions txList; for (auto const& txi: txs.transactions()) { - Transaction tx(txi.second, CheckSignature::Sender); - txList.push_back(tx); + txList.push_back(txi.second); mObject txObject; - txObject["nonce"] = toString(tx.nonce()); - txObject["data"] = "0x" + toHex(tx.data()); - txObject["gasLimit"] = toString(tx.gas()); - txObject["gasPrice"] = toString(tx.gasPrice()); - txObject["r"] = "0x" + toString(tx.signature().r); - txObject["s"] = "0x" + toString(tx.signature().s); - txObject["v"] = to_string(tx.signature().v + 27); - txObject["to"] = tx.isCreation() ? "" : toString(tx.receiveAddress()); - txObject["value"] = toString(tx.value()); + txObject["nonce"] = toString(txi.second.nonce()); + txObject["data"] = "0x" + toHex(txi.second.data()); + txObject["gasLimit"] = toString(txi.second.gas()); + txObject["gasPrice"] = toString(txi.second.gasPrice()); + txObject["r"] = "0x" + toString(txi.second.signature().r); + txObject["s"] = "0x" + toString(txi.second.signature().s); + txObject["v"] = to_string(txi.second.signature().v + 27); + txObject["to"] = txi.second.isCreation() ? "" : toString(txi.second.receiveAddress()); + txObject["value"] = toString(txi.second.value()); txArray.push_back(txObject); } diff --git a/checkRandomStateTest.cpp b/checkRandomStateTest.cpp index a4d390b1..49aca852 100644 --- a/checkRandomStateTest.cpp +++ b/checkRandomStateTest.cpp @@ -83,12 +83,11 @@ bool doStateTest(mValue& _v) ImportTest importer(o, false); eth::State theState = importer.m_statePre; - bytes tx = importer.m_transaction.rlp(); bytes output; try { - output = theState.execute(lastHashes(importer.m_environment.currentBlock.number), tx).output; + output = theState.execute(lastHashes(importer.m_environment.currentBlock.number), importer.m_transaction).output; } catch (Exception const& _e) { diff --git a/createRandomStateTest.cpp b/createRandomStateTest.cpp index f422d171..5758598b 100644 --- a/createRandomStateTest.cpp +++ b/createRandomStateTest.cpp @@ -183,12 +183,11 @@ void doStateTests(json_spirit::mValue& _v) test::ImportTest importer(o, true); eth::State theState = importer.m_statePre; - bytes tx = importer.m_transaction.rlp(); bytes output; try { - output = theState.execute(test::lastHashes(importer.m_environment.currentBlock.number), tx).output; + output = theState.execute(test::lastHashes(importer.m_environment.currentBlock.number), importer.m_transaction).output; } catch (Exception const& _e) { diff --git a/solidityExecutionFramework.h b/solidityExecutionFramework.h index 86062a90..2451aa38 100644 --- a/solidityExecutionFramework.h +++ b/solidityExecutionFramework.h @@ -142,7 +142,8 @@ protected: try { // this will throw since the transaction is invalid, but it should nevertheless store the transaction - executive.setup(&transactionRLP); + executive.initialize(&transactionRLP); + executive.execute(); } catch (...) {} if (_isCreation) @@ -57,13 +57,12 @@ void doStateTests(json_spirit::mValue& v, bool _fillin) ImportTest importer(o, _fillin); State theState = importer.m_statePre; - bytes tx = importer.m_transaction.rlp(); bytes output; try { Listener::ExecTimeGuard guard{i.first}; - output = theState.execute(lastHashes(importer.m_environment.currentBlock.number), tx).output; + output = theState.execute(lastHashes(importer.m_environment.currentBlock.number), importer.m_transaction).output; } catch (Exception const& _e) { diff --git a/stateOriginal.cpp b/stateOriginal.cpp index 5b7b0415..384d8534 100644 --- a/stateOriginal.cpp +++ b/stateOriginal.cpp @@ -79,13 +79,9 @@ BOOST_AUTO_TEST_CASE(Complex) cout << s; // Inject a transaction to transfer funds from miner to me. - bytes tx; - { - Transaction t(1000, 10000, 10000, me.address(), bytes(), s.transactionsFrom(myMiner.address()), myMiner.secret()); - assert(t.sender() == myMiner.address()); - tx = t.rlp(); - } - s.execute(bc, tx); + Transaction t(1000, 10000, 10000, me.address(), bytes(), s.transactionsFrom(myMiner.address()), myMiner.secret()); + assert(t.sender() == myMiner.address()); + s.execute(bc.lastHashes(), t); cout << s; |