|
@ -104,6 +104,7 @@ void MixClient::resetState(std::map<Secret, u256> _accounts) |
|
|
m_state = eth::State(genesisState.begin()->first , m_stateDB, BaseState::Empty); |
|
|
m_state = eth::State(genesisState.begin()->first , m_stateDB, BaseState::Empty); |
|
|
m_state.sync(bc()); |
|
|
m_state.sync(bc()); |
|
|
m_startState = m_state; |
|
|
m_startState = m_state; |
|
|
|
|
|
WriteGuard lx(x_executions); |
|
|
m_executions.clear(); |
|
|
m_executions.clear(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -186,12 +187,14 @@ void MixClient::executeTransaction(Transaction const& _t, State& _state, bool _c |
|
|
d.contractAddress = right160(sha3(rlpList(_t.sender(), _t.nonce()))); |
|
|
d.contractAddress = right160(sha3(rlpList(_t.sender(), _t.nonce()))); |
|
|
if (!_call) |
|
|
if (!_call) |
|
|
d.transactionIndex = m_state.pending().size(); |
|
|
d.transactionIndex = m_state.pending().size(); |
|
|
m_executions.emplace_back(std::move(d)); |
|
|
d.executonIndex = m_executions.size(); |
|
|
|
|
|
|
|
|
// execute on a state
|
|
|
// execute on a state
|
|
|
if (!_call) |
|
|
if (!_call) |
|
|
{ |
|
|
{ |
|
|
_state.execute(lastHashes, rlp, nullptr, true); |
|
|
_state.execute(lastHashes, rlp, nullptr, true); |
|
|
|
|
|
if (_t.isCreation() && _state.code(d.contractAddress).empty()) |
|
|
|
|
|
BOOST_THROW_EXCEPTION(OutOfGas() << errinfo_comment("Not enough gas for contract deployment")); |
|
|
// collect watches
|
|
|
// collect watches
|
|
|
h256Set changed; |
|
|
h256Set changed; |
|
|
Guard l(m_filterLock); |
|
|
Guard l(m_filterLock); |
|
@ -211,6 +214,8 @@ void MixClient::executeTransaction(Transaction const& _t, State& _state, bool _c |
|
|
changed.insert(dev::eth::PendingChangedFilter); |
|
|
changed.insert(dev::eth::PendingChangedFilter); |
|
|
noteChanged(changed); |
|
|
noteChanged(changed); |
|
|
} |
|
|
} |
|
|
|
|
|
WriteGuard l(x_executions); |
|
|
|
|
|
m_executions.emplace_back(std::move(d)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void MixClient::mine() |
|
|
void MixClient::mine() |
|
@ -226,14 +231,16 @@ void MixClient::mine() |
|
|
noteChanged(changed); |
|
|
noteChanged(changed); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
ExecutionResult const& MixClient::lastExecution() const |
|
|
ExecutionResult MixClient::lastExecution() const |
|
|
{ |
|
|
{ |
|
|
return m_executions.back(); |
|
|
ReadGuard l(x_executions); |
|
|
|
|
|
return m_executions.empty() ? ExecutionResult() : m_executions.back(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
ExecutionResults const& MixClient::executions() const |
|
|
ExecutionResult MixClient::execution(unsigned _index) const |
|
|
{ |
|
|
{ |
|
|
return m_executions; |
|
|
ReadGuard l(x_executions); |
|
|
|
|
|
return m_executions.at(_index); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
State MixClient::asOf(int _block) const |
|
|
State MixClient::asOf(int _block) const |
|
@ -441,32 +448,38 @@ LocalisedLogEntries MixClient::checkWatch(unsigned _watchId) |
|
|
|
|
|
|
|
|
h256 MixClient::hashFromNumber(unsigned _number) const |
|
|
h256 MixClient::hashFromNumber(unsigned _number) const |
|
|
{ |
|
|
{ |
|
|
|
|
|
ReadGuard l(x_state); |
|
|
return bc().numberHash(_number); |
|
|
return bc().numberHash(_number); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
eth::BlockInfo MixClient::blockInfo(h256 _hash) const |
|
|
eth::BlockInfo MixClient::blockInfo(h256 _hash) const |
|
|
{ |
|
|
{ |
|
|
|
|
|
ReadGuard l(x_state); |
|
|
return BlockInfo(bc().block(_hash)); |
|
|
return BlockInfo(bc().block(_hash)); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
eth::BlockInfo MixClient::blockInfo() const |
|
|
eth::BlockInfo MixClient::blockInfo() const |
|
|
{ |
|
|
{ |
|
|
|
|
|
ReadGuard l(x_state); |
|
|
return BlockInfo(bc().block()); |
|
|
return BlockInfo(bc().block()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
eth::BlockDetails MixClient::blockDetails(h256 _hash) const |
|
|
eth::BlockDetails MixClient::blockDetails(h256 _hash) const |
|
|
{ |
|
|
{ |
|
|
|
|
|
ReadGuard l(x_state); |
|
|
return bc().details(_hash); |
|
|
return bc().details(_hash); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Transaction MixClient::transaction(h256 _transactionHash) const |
|
|
Transaction MixClient::transaction(h256 _transactionHash) const |
|
|
{ |
|
|
{ |
|
|
|
|
|
ReadGuard l(x_state); |
|
|
return Transaction(bc().transaction(_transactionHash), CheckSignature::Range); |
|
|
return Transaction(bc().transaction(_transactionHash), CheckSignature::Range); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
eth::Transaction MixClient::transaction(h256 _blockHash, unsigned _i) const |
|
|
eth::Transaction MixClient::transaction(h256 _blockHash, unsigned _i) const |
|
|
{ |
|
|
{ |
|
|
|
|
|
ReadGuard l(x_state); |
|
|
auto bl = bc().block(_blockHash); |
|
|
auto bl = bc().block(_blockHash); |
|
|
RLP b(bl); |
|
|
RLP b(bl); |
|
|
if (_i < b[1].itemCount()) |
|
|
if (_i < b[1].itemCount()) |
|
@ -477,6 +490,7 @@ eth::Transaction MixClient::transaction(h256 _blockHash, unsigned _i) const |
|
|
|
|
|
|
|
|
eth::BlockInfo MixClient::uncle(h256 _blockHash, unsigned _i) const |
|
|
eth::BlockInfo MixClient::uncle(h256 _blockHash, unsigned _i) const |
|
|
{ |
|
|
{ |
|
|
|
|
|
ReadGuard l(x_state); |
|
|
auto bl = bc().block(_blockHash); |
|
|
auto bl = bc().block(_blockHash); |
|
|
RLP b(bl); |
|
|
RLP b(bl); |
|
|
if (_i < b[2].itemCount()) |
|
|
if (_i < b[2].itemCount()) |
|
@ -487,6 +501,7 @@ eth::BlockInfo MixClient::uncle(h256 _blockHash, unsigned _i) const |
|
|
|
|
|
|
|
|
unsigned MixClient::transactionCount(h256 _blockHash) const |
|
|
unsigned MixClient::transactionCount(h256 _blockHash) const |
|
|
{ |
|
|
{ |
|
|
|
|
|
ReadGuard l(x_state); |
|
|
auto bl = bc().block(_blockHash); |
|
|
auto bl = bc().block(_blockHash); |
|
|
RLP b(bl); |
|
|
RLP b(bl); |
|
|
return b[1].itemCount(); |
|
|
return b[1].itemCount(); |
|
@ -494,6 +509,7 @@ unsigned MixClient::transactionCount(h256 _blockHash) const |
|
|
|
|
|
|
|
|
unsigned MixClient::uncleCount(h256 _blockHash) const |
|
|
unsigned MixClient::uncleCount(h256 _blockHash) const |
|
|
{ |
|
|
{ |
|
|
|
|
|
ReadGuard l(x_state); |
|
|
auto bl = bc().block(_blockHash); |
|
|
auto bl = bc().block(_blockHash); |
|
|
RLP b(bl); |
|
|
RLP b(bl); |
|
|
return b[2].itemCount(); |
|
|
return b[2].itemCount(); |
|
@ -501,6 +517,7 @@ unsigned MixClient::uncleCount(h256 _blockHash) const |
|
|
|
|
|
|
|
|
Transactions MixClient::transactions(h256 _blockHash) const |
|
|
Transactions MixClient::transactions(h256 _blockHash) const |
|
|
{ |
|
|
{ |
|
|
|
|
|
ReadGuard l(x_state); |
|
|
auto bl = bc().block(_blockHash); |
|
|
auto bl = bc().block(_blockHash); |
|
|
RLP b(bl); |
|
|
RLP b(bl); |
|
|
Transactions res; |
|
|
Transactions res; |
|
@ -511,21 +528,25 @@ Transactions MixClient::transactions(h256 _blockHash) const |
|
|
|
|
|
|
|
|
TransactionHashes MixClient::transactionHashes(h256 _blockHash) const |
|
|
TransactionHashes MixClient::transactionHashes(h256 _blockHash) const |
|
|
{ |
|
|
{ |
|
|
|
|
|
ReadGuard l(x_state); |
|
|
return bc().transactionHashes(_blockHash); |
|
|
return bc().transactionHashes(_blockHash); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
unsigned MixClient::number() const |
|
|
unsigned MixClient::number() const |
|
|
{ |
|
|
{ |
|
|
|
|
|
ReadGuard l(x_state); |
|
|
return bc().number(); |
|
|
return bc().number(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
eth::Transactions MixClient::pending() const |
|
|
eth::Transactions MixClient::pending() const |
|
|
{ |
|
|
{ |
|
|
|
|
|
ReadGuard l(x_state); |
|
|
return m_state.pending(); |
|
|
return m_state.pending(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
eth::StateDiff MixClient::diff(unsigned _txi, h256 _block) const |
|
|
eth::StateDiff MixClient::diff(unsigned _txi, h256 _block) const |
|
|
{ |
|
|
{ |
|
|
|
|
|
ReadGuard l(x_state); |
|
|
State st(m_stateDB, bc(), _block); |
|
|
State st(m_stateDB, bc(), _block); |
|
|
return st.fromPending(_txi).diff(st.fromPending(_txi + 1)); |
|
|
return st.fromPending(_txi).diff(st.fromPending(_txi + 1)); |
|
|
} |
|
|
} |
|
|