Browse Source

cosmetic changes

cl-refactor
yann300 10 years ago
parent
commit
ec62858be1
  1. 2
      mix/ClientModel.cpp
  2. 5
      mix/ClientModel.h
  3. 55
      mix/MixClient.cpp
  4. 3
      mix/MixClient.h
  5. 5
      mix/qml/BlockChain.qml
  6. 3
      mix/qml/QAddressView.qml
  7. 5
      mix/qml/StateListModel.qml

2
mix/ClientModel.cpp

@ -438,7 +438,7 @@ std::pair<QString, int> ClientModel::resolvePair(QString const& _contractId)
QString ClientModel::resolveToken(std::pair<QString, int> const& _value)
{
if (_value.second == -2)
if (_value.second == -2) //-2: first contains a real address
return _value.first;
else if (m_contractAddresses.size() > 0)
return QString::fromStdString("0x" + dev::toHex(m_contractAddresses[_value].ref()));

5
mix/ClientModel.h

@ -185,13 +185,10 @@ public:
Q_INVOKABLE QString toHex(QString const& _int);
public slots:
/// Setup state, run transaction sequence, show debugger for the last transaction
/// @param _state JS object with state configuration
//void setupState(QVariantMap _state);
/// Setup scenario, run transaction sequence, show debugger for the last transaction
/// @param _state JS object with state configuration
void setupScenario(QVariantMap _scenario);
/// Execute the given @param _tr on the curret state
/// Execute the given @param _tr on the current state
void executeTr(QVariantMap _tr);
/// Show the debugger for a specified record
Q_INVOKABLE void debugRecord(unsigned _index);

55
mix/MixClient.cpp

@ -73,25 +73,11 @@ MixClient::MixClient(std::string const& _dbPath):
resetState(std::unordered_map<Address, Account>());
}
MixClient::~MixClient()
{
}
LocalisedLogEntries MixClient::logs()
{
return m_watches.at(0).changes;
}
void MixClient::resetState(std::unordered_map<Address, Account> const& _accounts, Secret const& _miner)
{
WriteGuard l(x_state);
Guard fl(x_filtersWatches);
m_filters.clear();
m_watches.clear();
//LogFilter filter;
//m_filters.insert(std::make_pair(filter.sha3(), filter));
//m_watches.insert(std::make_pair(0, ClientWatch(filter.sha3(), Reaping::Automatic)));
m_stateDB = OverlayDB();
SecureTrieDB<Address, MemoryDB> accountState(&m_stateDB);
@ -261,39 +247,15 @@ void MixClient::executeTransaction(Transaction const& _t, State& _state, bool _c
if (t.isCreation() && _state.code(d.contractAddress).empty())
BOOST_THROW_EXCEPTION(OutOfGas() << errinfo_comment("Not enough gas for contract deployment"));
d.gasUsed = er.gasUsed + er.gasRefunded + er.gasForDeposit + c_callStipend;
// collect watches
h256Set changed;
Guard l(x_filtersWatches);
LocalisedLogEntries logs;
//for (unsigned i = 0; i < _state.pending().size(); ++i)
//{
TransactionReceipt const& tr = _state.receipt(_state.pending().size() - 1);
auto trHash = _state.pending().at(_state.pending().size() - 1).sha3();
//for (std::pair<h256 const, eth::InstalledFilter>& installedFilter: m_filters)
//{
LogEntries le = tr.log(); // installedFilter.second.filter.matches(tr);
LogEntries le = tr.log();
if (le.size())
for (unsigned j = 0; j < le.size(); ++j)
logs.insert(logs.begin(), LocalisedLogEntry(le[j], bc().number() + 1, trHash));
//}
//}
/*if ((unsigned)i.second.filter.latest() > bc().number())
{
// acceptable number.
auto m = i.second.filter.matches(_state.receipt(_state.pending().size() - 1));
if (m.size())
{
// filter catches them
for (LogEntry const& l: m)
i.second.changes.push_back(LocalisedLogEntry(l, bc().number() + 1));
changed.insert(i.first);
}
}*/
changed.insert(dev::eth::PendingChangedFilter);
d.logs = logs;
//noteChanged(changed);
}
WriteGuard l(x_executions);
m_executions.emplace_back(std::move(d));
@ -308,7 +270,6 @@ void MixClient::mine()
m_state.sync(bc());
m_startState = m_state;
h256Set changed { dev::eth::PendingChangedFilter, dev::eth::ChainChangedFilter };
//noteChanged(changed);
}
ExecutionResult MixClient::lastExecution() const
@ -395,20 +356,6 @@ dev::eth::ExecutionResult MixClient::create(Address const& _from, u256 _value, b
return lastExecution().result;
}
/*void MixClient::noteChanged(h256Set const& _filters)
{
for (auto& i: m_watches)
if (_filters.count(i.second.id))
{
if (m_filters.count(i.second.id))
i.second.changes += m_filters.at(i.second.id).changes;
else
i.second.changes.push_back(LocalisedLogEntry(SpecialLogEntry, 0));
}
for (auto& i: m_filters)
i.second.changes.clear();
}*/
eth::BlockInfo MixClient::blockInfo() const
{
ReadGuard l(x_state);

3
mix/MixClient.h

@ -77,8 +77,6 @@ public:
using Interface::blockInfo; // to remove warning about hiding virtual function
eth::BlockInfo blockInfo() const;
dev::eth::LocalisedLogEntries logs();
protected:
/// ClientBase methods
using ClientBase::asOf;
@ -91,7 +89,6 @@ protected:
private:
void executeTransaction(dev::eth::Transaction const& _t, eth::State& _state, bool _call, bool _gasAuto, dev::Secret const& _secret = dev::Secret());
//void noteChanged(h256Set const& _filters);
dev::eth::Transaction replaceGas(dev::eth::Transaction const& _t, dev::u256 const& _gas, dev::Secret const& _secret = dev::Secret());
eth::State m_state;

5
mix/qml/BlockChain.qml

@ -307,7 +307,6 @@ ColumnLayout {
onClicked:
{
var lastBlock = model.blocks[model.blocks.length - 1];
console.log(lastBlock.status + "!!!")
if (lastBlock.status === "mined")
{
var newblock = projectModel.stateListModel.createEmptyBlock()
@ -376,7 +375,6 @@ ColumnLayout {
target: clientModel
onNewBlock:
{
console.log("new Block!!")
if (!clientModel.running)
{
var lastBlock = model.blocks[model.blocks.length - 1]
@ -430,7 +428,6 @@ ColumnLayout {
itemTr.sender = _r.sender
itemTr.recordIndex = _r.recordIndex
itemTr.logs = _r.logs
console.log(JSON.stringify(itemTr))
model.blocks[model.blocks.length - 1].transactions.push(itemTr)
blockModel.appendTransaction(itemTr)
}
@ -460,9 +457,7 @@ ColumnLayout {
var item = transactionDialog.getItem()
if (execute)
{
console.log("cc " + model.blocks.length)
var lastBlock = model.blocks[model.blocks.length - 1];
console.log("mined?" + lastBlock.status)
if (lastBlock.status === "mined")
{
var newBlock = projectModel.stateListModel.createEmptyBlock();

3
mix/qml/QAddressView.qml

@ -39,9 +39,6 @@ Item
{
accountRef.clear();
accountRef.append({"itemid": " - "});
console.log(blockIndex)
console.log(transactionIndex)
if (subType === "contract" || subType === "address")
{
var trCr = 0;

5
mix/qml/StateListModel.qml

@ -42,6 +42,7 @@ Item {
for (var j in ret.transactions)
ret.blocks[0].transactions.push(fromPlainTransactionItem(toPlainTransactionItem(ret.transactions[j])))
}
return ret;
}
function fromPlainAccountItem(t)
@ -377,8 +378,8 @@ Item {
function runState(index) {
var item = stateList[index];
//clientModel.setupState(item);
//stateRun(index);
clientModel.setupScenario(item);
stateRun(index);
}
function deleteState(index) {

Loading…
Cancel
Save