summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmir Taaki <genjix@riseup.net>2014-05-09 11:29:20 (GMT)
committer Amir Taaki <genjix@riseup.net>2014-05-09 11:29:20 (GMT)
commitce962e73bd04fe3733575c67ebb5f2c8aa2593b7 (patch)
tree7a38b70d88db11c7414dc2b87d02a4f8a531ad9e
parent121ad026c1ffc9d43945e26d301feadbe94ce570 (diff)
allow fetch-stealth to optionally take no arguments (defaults to 0/00000000)
-rw-r--r--src/fetch-stealth.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/fetch-stealth.cpp b/src/fetch-stealth.cpp
index bf8f66f..da15362 100644
--- a/src/fetch-stealth.cpp
+++ b/src/fetch-stealth.cpp
@@ -26,7 +26,7 @@ void stealth_fetched(const std::error_code& ec,
int main(int argc, char** argv)
{
- if (argc != 3 && argc != 4)
+ if (argc != 1 && argc != 3 && argc != 4)
{
std::cerr << "Usage: fetch-stealth NUMBER_BITS BITFIELD [FROM_HEIGHT]"
<< std::endl;
@@ -35,10 +35,13 @@ int main(int argc, char** argv)
size_t from_height = 0;
if (argc == 4)
from_height = boost::lexical_cast<size_t>(argv[3]);
- stealth_prefix prefix;
- prefix.number_bits = boost::lexical_cast<int>(argv[1]);
- data_chunk bitfield_bytes = decode_hex(argv[2]);
- prefix.bitfield = cast_chunk<uint32_t>(bitfield_bytes);
+ stealth_prefix prefix{0, 0};
+ if (argc >= 3)
+ {
+ prefix.number_bits = boost::lexical_cast<int>(argv[1]);
+ data_chunk bitfield_bytes = decode_hex(argv[2]);
+ prefix.bitfield = from_little_endian<uint32_t>(bitfield_bytes.begin());
+ }
// Start Obelisk
config_map_type config;
load_config(config);