diff --git a/tools/dht_put.cpp b/tools/dht_put.cpp index c3c4fc42a..ec4d40c80 100644 --- a/tools/dht_put.cpp +++ b/tools/dht_put.cpp @@ -108,10 +108,12 @@ void usage() " the specified file\n" "dump-key - dump ed25519 keypair from the specified key\n" " file.\n" - "mput - puts the specified string as a mutable\n" - " object under the public key in key-file\n" - "mget - get a mutable object under the specified\n" - " public key\n" + "mput [salt]\n" + " - puts the specified string as a mutable\n" + " object under the public key in key-file,\n" + " and optionally specified salt\n" + "mget [salt] - get a mutable object under the specified\n" + " public key, and salt (optional)\n" ); exit(1); } @@ -126,10 +128,9 @@ alert* wait_for_alert(lt::session& s, int alert_type) std::vector alerts; s.pop_alerts(&alerts); - for (std::vector::iterator i = alerts.begin() - , end(alerts.end()); i != end; ++i) + for (auto const a : alerts) { - if ((*i)->type() != alert_type) + if (a->type() != alert_type) { static int spinner = 0; static const char anim[] = {'-', '\\', '|', '/'}; @@ -139,7 +140,7 @@ alert* wait_for_alert(lt::session& s, int alert_type) //print some alerts? continue; } - ret = *i; + ret = a; found = true; } } @@ -360,12 +361,16 @@ int main(int argc, char* argv[]) public_key pk; secret_key sk; std::tie(pk, sk) = ed25519_create_keypair(seed); + std::string salt; + + if (argc > 1) salt = argv[1]; bootstrap(s); s.dht_put_item(pk.bytes, std::bind(&put_string, _1, _2, _3, _4 - , pk.bytes, sk.bytes, argv[0])); + , pk.bytes, sk.bytes, argv[0]), salt); - std::printf("MPUT public key: %s\n", to_hex(pk.bytes).c_str()); + std::printf("MPUT public key: %s [salt: %s]\n", to_hex(pk.bytes).c_str() + , salt.c_str()); alert* a = wait_for_alert(s, dht_put_alert::alert_type); dht_put_alert* pa = alert_cast(a); @@ -390,9 +395,12 @@ int main(int argc, char* argv[]) return 1; } + std::string salt; + if (argc > 1) salt = argv[1]; + bootstrap(s); - s.dht_get_item(public_key); - std::printf("MGET %s\n", argv[0]); + s.dht_get_item(public_key, salt); + std::printf("MGET %s [salt: %s]\n", argv[0], salt.c_str()); bool authoritative = false;