Browse Source

Better handling of data.

cl-refactor
Gav Wood 11 years ago
parent
commit
d13acb6464
  1. 5
      alethzero/Main.ui
  2. 34
      alethzero/MainWin.cpp
  3. 2
      alethzero/MainWin.h
  4. 1
      eth/main.cpp

5
alethzero/Main.ui

@ -431,7 +431,7 @@
<number>430000000</number>
</property>
<property name="value">
<number>1000</number>
<number>0</number>
</property>
</widget>
</item>
@ -491,6 +491,9 @@
<property name="maximum">
<number>430000000</number>
</property>
<property name="value">
<number>10000</number>
</property>
</widget>
</item>
<item row="2" column="3">

34
alethzero/MainWin.cpp

@ -509,25 +509,49 @@ void Main::on_data_textChanged()
m_data = compileLisp(code, true, m_init);
ui->code->setPlainText(QString::fromStdString(disassemble(m_data)) + "\n; Init:" + QString::fromStdString(disassemble(m_init)));
ui->gas->setMinimum((qint64)state().createGas(m_data.size() + m_init.size(), 0));
if (!ui->gas->isEnabled())
ui->gas->setValue(m_backupGas);
ui->gas->setEnabled(true);
}
else
{
string code = ui->data->toPlainText().replace(" ", "").replace("\n", "").replace("\t", "").toStdString();
try
m_data.clear();
QString s = ui->data->toPlainText();
while (s.size())
{
m_data = fromHex(code);
QRegExp r("@?\"(.*)\"(.*)");
QRegExp h("([a-fA-F0-9][a-fA-F0-9])(.*)");
if (r.exactMatch(s))
{
for (auto i: r.cap(1))
m_data.push_back((byte)i.toLatin1());
if (s[0] == '@')
m_data.push_back(0);
else
for (int i = r.cap(1).size(); i < 32; ++i)
m_data.push_back(0);
s = r.cap(2);
}
else if (h.exactMatch(s))
{
m_data.push_back(fromHex(h.cap(1).toStdString())[0]);
s = h.cap(2);
}
else
s = s.mid(1);
}
catch (...)
{}
ui->code->setPlainText(QString::fromStdString(toHex(m_data)));
if (m_client->postState().isContractAddress(fromString(ui->destination->text())))
{
ui->gas->setMinimum((qint64)state().callGas(m_data.size(), 1));
if (!ui->gas->isEnabled())
ui->gas->setValue(m_backupGas);
ui->gas->setEnabled(true);
}
else
{
if (ui->gas->isEnabled())
m_backupGas = ui->gas->value();
ui->gas->setValue((qint64)state().callGas(m_data.size()));
ui->gas->setEnabled(false);
}

2
alethzero/MainWin.h

@ -87,6 +87,8 @@ private:
eth::bytes m_init;
eth::Address m_nameReg;
unsigned m_backupGas;
QNetworkAccessManager m_webCtrl;
};

1
eth/main.cpp

@ -219,6 +219,7 @@ int nc_window_streambuf::overflow(int c)
int my = 0;
getyx(m_pnl, y, x);
getmaxyx(m_pnl, my, mx);
(void)my;
if (y < 1)
y = 1;
if (x < 2)

Loading…
Cancel
Save