Browse Source

fix styling, addr len check

cl-refactor
Joey Zhou 11 years ago
parent
commit
34aacb27ca
  1. 53
      eth/main.cpp

53
eth/main.cpp

@ -418,7 +418,8 @@ int main(int argc, char** argv)
auto h = bc.currentHash(); auto h = bc.currentHash();
auto blockData = bc.block(h); auto blockData = bc.block(h);
BlockInfo info(blockData); BlockInfo info(blockData);
if(iss.peek()!=-1){ if (iss.peek()!=-1)
{
string hexAddr; string hexAddr;
u256 amount; u256 amount;
u256 gasPrice; u256 gasPrice;
@ -462,9 +463,9 @@ int main(int argc, char** argv)
Address dest = h160(fromHex(hexAddr)); Address dest = h160(fromHex(hexAddr));
c.transact(secret, amount, dest, data, gas, gasPrice); c.transact(secret, amount, dest, data, gas, gasPrice);
} }
} else {
cwarn << "Require parameters: transact ADDRESS AMOUNT GASPRICE GAS SECRET DATA";
} }
else
cwarn << "Require parameters: transact ADDRESS AMOUNT GASPRICE GAS SECRET DATA";
} }
else if (cmd == "listContracts") else if (cmd == "listContracts")
{ {
@ -502,7 +503,8 @@ int main(int argc, char** argv)
else if (cmd == "send") else if (cmd == "send")
{ {
ClientGuard g(&c); ClientGuard g(&c);
if(iss.peek() != -1){ if (iss.peek() != -1)
{
string hexAddr; string hexAddr;
u256 amount; u256 amount;
int size = hexAddr.length(); int size = hexAddr.length();
@ -513,9 +515,10 @@ int main(int argc, char** argv)
if (size > 0) if (size > 0)
cwarn << "Invalid address length: " << size; cwarn << "Invalid address length: " << size;
} }
else if (amount < 0) { else if (amount < 0)
cwarn << "Invalid amount: " << amount; cwarn << "Invalid amount: " << amount;
} else { else
{
auto const& bc = c.blockChain(); auto const& bc = c.blockChain();
auto h = bc.currentHash(); auto h = bc.currentHash();
auto blockData = bc.block(h); auto blockData = bc.block(h);
@ -525,9 +528,9 @@ int main(int argc, char** argv)
c.transact(us.secret(), amount, dest, bytes(), minGas, info.minGasPrice); c.transact(us.secret(), amount, dest, bytes(), minGas, info.minGasPrice);
} }
} else {
cwarn << "Require parameters: send ADDRESS AMOUNT";
} }
else
cwarn << "Require parameters: send ADDRESS AMOUNT";
} }
else if (cmd == "contract") else if (cmd == "contract")
{ {
@ -568,13 +571,11 @@ int main(int argc, char** argv)
else if (gas < minGas) else if (gas < minGas)
cwarn << "Minimum gas amount is " << minGas; cwarn << "Minimum gas amount is " << minGas;
else else
{
c.transact(us.secret(), endowment, init, gas, gasPrice); c.transact(us.secret(), endowment, init, gas, gasPrice);
} }
} else { else
cwarn << "Require parameters: contract ENDOWMENT GASPRICE GAS CODEHEX"; cwarn << "Require parameters: contract ENDOWMENT GASPRICE GAS CODEHEX";
} }
}
else if (cmd == "inspect") else if (cmd == "inspect")
{ {
string rechex; string rechex;
@ -602,39 +603,43 @@ int main(int argc, char** argv)
} }
else if (cmd == "setSecret") else if (cmd == "setSecret")
{ {
if(iss.peek() != -1) { if (iss.peek() != -1)
{
string hexSec; string hexSec;
iss >> hexSec; iss >> hexSec;
us = KeyPair(h256(fromHex(hexSec))); us = KeyPair(h256(fromHex(hexSec)));
} else {
cwarn << "Require parameter: setSecret HEXSECRETKEY";
} }
else
cwarn << "Require parameter: setSecret HEXSECRETKEY";
} }
else if (cmd == "setAddress") else if (cmd == "setAddress")
{ {
if(iss.peek() != -1) { if (iss.peek() != -1)
{
string hexAddr; string hexAddr;
iss >> hexAddr; iss >> hexAddr;
coinbase = h160(fromHex(hexAddr)); coinbase = h160(fromHex(hexAddr));
} else {
cwarn << "Require parameter: setAddress HEXADDRESS";
} }
else
cwarn << "Require parameter: setAddress HEXADDRESS";
} }
else if (cmd == "exportConfig") else if (cmd == "exportConfig")
{ {
if(iss.peek() != -1) { if (iss.peek() != -1)
{
string path; string path;
iss >> path; iss >> path;
RLPStream config(2); RLPStream config(2);
config << us.secret() << coinbase; config << us.secret() << coinbase;
writeFile(path, config.out()); writeFile(path, config.out());
} else {
cwarn << "Require parameter: exportConfig PATH";
} }
else
cwarn << "Require parameter: exportConfig PATH";
} }
else if (cmd == "importConfig") else if (cmd == "importConfig")
{ {
if(iss.peek() != -1) { if (iss.peek() != -1)
{
string path; string path;
iss >> path; iss >> path;
bytes b = contents(path); bytes b = contents(path);
@ -643,13 +648,13 @@ int main(int argc, char** argv)
RLP config(b); RLP config(b);
us = KeyPair(config[0].toHash<Secret>()); us = KeyPair(config[0].toHash<Secret>());
coinbase = config[1].toHash<Address>(); coinbase = config[1].toHash<Address>();
} else { }
else
cwarn << path << " has no content!"; cwarn << path << " has no content!";
} }
} else { else
cwarn << "Require parameter: importConfig PATH"; cwarn << "Require parameter: importConfig PATH";
} }
}
else if (cmd == "help") else if (cmd == "help")
interactiveHelp(); interactiveHelp();
else if (cmd == "exit") else if (cmd == "exit")

Loading…
Cancel
Save