未验证 提交 6ff40389 编写于 作者: K Kevin Heifner 提交者: GitHub

Merge pull request #641 from EOSIO/trx-expiration-635

Transaction expiration in eosc
...@@ -202,20 +202,20 @@ vector<uint8_t> assemble_wast( const std::string& wast ) { ...@@ -202,20 +202,20 @@ vector<uint8_t> assemble_wast( const std::string& wast ) {
} }
} }
auto tx_expiration = fc::seconds(1); auto tx_expiration = fc::seconds(30);
bool tx_force_unique = false; bool tx_force_unique = false;
void add_standard_transaction_options(CLI::App* cmd) { void add_standard_transaction_options(CLI::App* cmd) {
CLI::callback_t parse_exipration = [](CLI::results_t res) -> bool { CLI::callback_t parse_exipration = [](CLI::results_t res) -> bool {
double value_ms; double value_s;
if (res.size() == 0 || !CLI::detail::lexical_cast(res[0], value_ms)) { if (res.size() == 0 || !CLI::detail::lexical_cast(res[0], value_s)) {
return false; return false;
} }
tx_expiration = fc::microseconds(static_cast<uint64_t>(value_ms * 1000.0)); tx_expiration = fc::seconds(static_cast<uint64_t>(value_s));
return true; return true;
}; };
cmd->add_option("-x,--expiration", parse_exipration, localized("set the time in milliseconds before a transaction expires, defaults to 1000ms")); cmd->add_option("-x,--expiration", parse_exipration, localized("set the time in seconds before a transaction expires, defaults to 30s"));
cmd->add_flag("-f,--force-unique", tx_force_unique, localized("force the transaction to be unique. this will consume extra bandwidth and remove any protections against accidently issuing the same transaction multiple times")); cmd->add_flag("-f,--force-unique", tx_force_unique, localized("force the transaction to be unique. this will consume extra bandwidth and remove any protections against accidently issuing the same transaction multiple times"));
} }
...@@ -360,6 +360,7 @@ struct set_account_permission_subcommand { ...@@ -360,6 +360,7 @@ struct set_account_permission_subcommand {
permissions->add_option("authority", authorityJsonOrFile, localized("[delete] NULL, [create/update] JSON string or filename defining the authority"))->required(); permissions->add_option("authority", authorityJsonOrFile, localized("[delete] NULL, [create/update] JSON string or filename defining the authority"))->required();
permissions->add_option("parent", parentStr, localized("[create] The permission name of this parents permission (Defaults to: \"Active\")")); permissions->add_option("parent", parentStr, localized("[create] The permission name of this parents permission (Defaults to: \"Active\")"));
permissions->add_flag("-s,--skip-sign", skip_sign, localized("Specify if unlocked wallet keys should be used to sign transaction")); permissions->add_flag("-s,--skip-sign", skip_sign, localized("Specify if unlocked wallet keys should be used to sign transaction"));
add_standard_transaction_options(permissions);
permissions->set_callback([this] { permissions->set_callback([this] {
Name account = Name(accountStr); Name account = Name(accountStr);
...@@ -426,6 +427,7 @@ struct set_action_permission_subcommand { ...@@ -426,6 +427,7 @@ struct set_action_permission_subcommand {
permissions->add_option("type", typeStr, localized("the type of the action"))->required(); permissions->add_option("type", typeStr, localized("the type of the action"))->required();
permissions->add_option("requirement", requirementStr, localized("[delete] NULL, [set/update] The permission name require for executing the given action"))->required(); permissions->add_option("requirement", requirementStr, localized("[delete] NULL, [set/update] The permission name require for executing the given action"))->required();
permissions->add_flag("-s,--skip-sign", skip_sign, localized("Specify if unlocked wallet keys should be used to sign transaction")); permissions->add_flag("-s,--skip-sign", skip_sign, localized("Specify if unlocked wallet keys should be used to sign transaction"));
add_standard_transaction_options(permissions);
permissions->set_callback([this] { permissions->set_callback([this] {
Name account = Name(accountStr); Name account = Name(accountStr);
...@@ -486,6 +488,7 @@ int main( int argc, char** argv ) { ...@@ -486,6 +488,7 @@ int main( int argc, char** argv ) {
createAccount->add_option("OwnerKey", ownerKey, localized("The owner public key for the account"))->required(); createAccount->add_option("OwnerKey", ownerKey, localized("The owner public key for the account"))->required();
createAccount->add_option("ActiveKey", activeKey, localized("The active public key for the account"))->required(); createAccount->add_option("ActiveKey", activeKey, localized("The active public key for the account"))->required();
createAccount->add_flag("-s,--skip-signature", skip_sign, localized("Specify that unlocked wallet keys should not be used to sign transaction")); createAccount->add_flag("-s,--skip-signature", skip_sign, localized("Specify that unlocked wallet keys should not be used to sign transaction"));
add_standard_transaction_options(createAccount);
createAccount->set_callback([&] { createAccount->set_callback([&] {
create_account(creator, name, public_key_type(ownerKey), public_key_type(activeKey), !skip_sign); create_account(creator, name, public_key_type(ownerKey), public_key_type(activeKey), !skip_sign);
}); });
...@@ -498,6 +501,7 @@ int main( int argc, char** argv ) { ...@@ -498,6 +501,7 @@ int main( int argc, char** argv ) {
createProducer->add_option("-p,--permission", permissions, createProducer->add_option("-p,--permission", permissions,
localized("An account and permission level to authorize, as in 'account@permission' (default user@active)")); localized("An account and permission level to authorize, as in 'account@permission' (default user@active)"));
createProducer->add_flag("-s,--skip-signature", skip_sign, localized("Specify that unlocked wallet keys should not be used to sign transaction")); createProducer->add_flag("-s,--skip-signature", skip_sign, localized("Specify that unlocked wallet keys should not be used to sign transaction"));
add_standard_transaction_options(createProducer);
createProducer->set_callback([&name, &ownerKey, &permissions, &skip_sign] { createProducer->set_callback([&name, &ownerKey, &permissions, &skip_sign] {
if (permissions.empty()) { if (permissions.empty()) {
permissions.push_back(name + "@active"); permissions.push_back(name + "@active");
...@@ -671,6 +675,7 @@ int main( int argc, char** argv ) { ...@@ -671,6 +675,7 @@ int main( int argc, char** argv ) {
auto abi = contractSubcommand->add_option("abi-file,-a,--abi", abiPath, localized("The ABI for the contract")) auto abi = contractSubcommand->add_option("abi-file,-a,--abi", abiPath, localized("The ABI for the contract"))
->check(CLI::ExistingFile); ->check(CLI::ExistingFile);
contractSubcommand->add_flag("-s,--skip-sign", skip_sign, localized("Specify if unlocked wallet keys should be used to sign transaction")); contractSubcommand->add_flag("-s,--skip-sign", skip_sign, localized("Specify if unlocked wallet keys should be used to sign transaction"));
add_standard_transaction_options(contractSubcommand);
contractSubcommand->set_callback([&] { contractSubcommand->set_callback([&] {
std::string wast; std::string wast;
std::cout << localized("Reading WAST...") << std::endl; std::cout << localized("Reading WAST...") << std::endl;
...@@ -704,6 +709,7 @@ int main( int argc, char** argv ) { ...@@ -704,6 +709,7 @@ int main( int argc, char** argv ) {
producerSubcommand->add_option("-p,--permission", permissions, producerSubcommand->add_option("-p,--permission", permissions,
localized("An account and permission level to authorize, as in 'account@permission' (default user@active)")); localized("An account and permission level to authorize, as in 'account@permission' (default user@active)"));
producerSubcommand->add_flag("-s,--skip-signature", skip_sign, localized("Specify that unlocked wallet keys should not be used to sign transaction")); producerSubcommand->add_flag("-s,--skip-signature", skip_sign, localized("Specify that unlocked wallet keys should not be used to sign transaction"));
add_standard_transaction_options(producerSubcommand);
producerSubcommand->set_callback([&] { producerSubcommand->set_callback([&] {
// don't need to check unapproveCommand because one of approve or unapprove is required // don't need to check unapproveCommand because one of approve or unapprove is required
bool approve = producerSubcommand->got_subcommand(approveCommand); bool approve = producerSubcommand->got_subcommand(approveCommand);
...@@ -730,6 +736,7 @@ int main( int argc, char** argv ) { ...@@ -730,6 +736,7 @@ int main( int argc, char** argv ) {
proxySubcommand->add_option("-p,--permission", permissions, proxySubcommand->add_option("-p,--permission", permissions,
localized("An account and permission level to authorize, as in 'account@permission' (default user@active)")); localized("An account and permission level to authorize, as in 'account@permission' (default user@active)"));
proxySubcommand->add_flag("-s,--skip-signature", skip_sign, localized("Specify that unlocked wallet keys should not be used to sign transaction")); proxySubcommand->add_flag("-s,--skip-signature", skip_sign, localized("Specify that unlocked wallet keys should not be used to sign transaction"));
add_standard_transaction_options(proxySubcommand);
proxySubcommand->set_callback([&] { proxySubcommand->set_callback([&] {
if (permissions.empty()) { if (permissions.empty()) {
permissions.push_back(name + "@active"); permissions.push_back(name + "@active");
...@@ -901,6 +908,7 @@ int main( int argc, char** argv ) { ...@@ -901,6 +908,7 @@ int main( int argc, char** argv ) {
auto benchmark_setup = benchmark->add_subcommand( "setup", localized("Configures initial condition for benchmark") ); auto benchmark_setup = benchmark->add_subcommand( "setup", localized("Configures initial condition for benchmark") );
uint64_t number_of_accounts = 2; uint64_t number_of_accounts = 2;
benchmark_setup->add_option("accounts", number_of_accounts, localized("the number of accounts in transfer among"))->required(); benchmark_setup->add_option("accounts", number_of_accounts, localized("the number of accounts in transfer among"))->required();
add_standard_transaction_options(benchmark_setup);
benchmark_setup->set_callback([&]{ benchmark_setup->set_callback([&]{
std::cerr << localized("Creating ${number_of_accounts} accounts with initial balances", ("number_of_accounts",number_of_accounts)) << std::endl; std::cerr << localized("Creating ${number_of_accounts} accounts with initial balances", ("number_of_accounts",number_of_accounts)) << std::endl;
EOSC_ASSERT( number_of_accounts >= 2, "must create at least 2 accounts" ); EOSC_ASSERT( number_of_accounts >= 2, "must create at least 2 accounts" );
...@@ -940,6 +948,7 @@ int main( int argc, char** argv ) { ...@@ -940,6 +948,7 @@ int main( int argc, char** argv ) {
benchmark_transfer->add_option("accounts", number_of_accounts, localized("the number of accounts in transfer among"))->required(); benchmark_transfer->add_option("accounts", number_of_accounts, localized("the number of accounts in transfer among"))->required();
benchmark_transfer->add_option("count", number_of_transfers, localized("the number of transfers to execute"))->required(); benchmark_transfer->add_option("count", number_of_transfers, localized("the number of transfers to execute"))->required();
benchmark_transfer->add_option("loop", loop, localized("whether or not to loop for ever")); benchmark_transfer->add_option("loop", loop, localized("whether or not to loop for ever"));
add_standard_transaction_options(benchmark_transfer);
benchmark_transfer->set_callback([&]{ benchmark_transfer->set_callback([&]{
EOSC_ASSERT( number_of_accounts >= 2, "must create at least 2 accounts" ); EOSC_ASSERT( number_of_accounts >= 2, "must create at least 2 accounts" );
...@@ -1030,6 +1039,7 @@ int main( int argc, char** argv ) { ...@@ -1030,6 +1039,7 @@ int main( int argc, char** argv ) {
localized("An account and permission level to authorize, as in 'account@permission'")); localized("An account and permission level to authorize, as in 'account@permission'"));
messageSubcommand->add_option("-S,--scope", scopes, localized("An comma separated list of accounts in scope for this operation"), true); messageSubcommand->add_option("-S,--scope", scopes, localized("An comma separated list of accounts in scope for this operation"), true);
messageSubcommand->add_flag("-s,--skip-sign", skip_sign, localized("Specify that unlocked wallet keys should not be used to sign transaction")); messageSubcommand->add_flag("-s,--skip-sign", skip_sign, localized("Specify that unlocked wallet keys should not be used to sign transaction"));
add_standard_transaction_options(messageSubcommand);
messageSubcommand->set_callback([&] { messageSubcommand->set_callback([&] {
ilog("Converting argument to binary..."); ilog("Converting argument to binary...");
auto arg= fc::mutable_variant_object auto arg= fc::mutable_variant_object
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册