forked from libbitcoin/libbitcoin-explorer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add subscribe-tx and subscribe-block commands
- Loading branch information
1 parent
ff88084
commit b59b0c6
Showing
20 changed files
with
919 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,270 @@ | ||
/** | ||
* Copyright (c) 2011-2017 libbitcoin developers (see AUTHORS) | ||
* | ||
* This file is part of libbitcoin. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
#ifndef BX_SUBSCRIBE_BLOCK_HPP | ||
#define BX_SUBSCRIBE_BLOCK_HPP | ||
|
||
#include <cstdint> | ||
#include <iostream> | ||
#include <string> | ||
#include <vector> | ||
#include <boost/program_options.hpp> | ||
#include <bitcoin/bitcoin.hpp> | ||
#include <bitcoin/explorer/command.hpp> | ||
#include <bitcoin/explorer/define.hpp> | ||
#include <bitcoin/explorer/generated.hpp> | ||
#include <bitcoin/explorer/config/address.hpp> | ||
#include <bitcoin/explorer/config/algorithm.hpp> | ||
#include <bitcoin/explorer/config/btc.hpp> | ||
#include <bitcoin/explorer/config/byte.hpp> | ||
#include <bitcoin/explorer/config/cert_key.hpp> | ||
#include <bitcoin/explorer/config/ec_private.hpp> | ||
#include <bitcoin/explorer/config/electrum.hpp> | ||
#include <bitcoin/explorer/config/encoding.hpp> | ||
#include <bitcoin/explorer/config/endorsement.hpp> | ||
#include <bitcoin/explorer/config/hashtype.hpp> | ||
#include <bitcoin/explorer/config/hd_key.hpp> | ||
#include <bitcoin/explorer/config/language.hpp> | ||
#include <bitcoin/explorer/config/raw.hpp> | ||
#include <bitcoin/explorer/config/signature.hpp> | ||
#include <bitcoin/explorer/config/wrapper.hpp> | ||
#include <bitcoin/explorer/utility.hpp> | ||
|
||
/********* GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY **********/ | ||
|
||
namespace libbitcoin { | ||
namespace explorer { | ||
namespace commands { | ||
|
||
/** | ||
* Various localizable strings. | ||
*/ | ||
#define BX_SUBSCRIBE_BLOCK_FAILED \ | ||
"Failed to subscribe to transaction service: %1%" | ||
|
||
/** | ||
* Class to implement the subscribe-block command. | ||
*/ | ||
class BCX_API subscribe_block | ||
: public command | ||
{ | ||
public: | ||
|
||
/** | ||
* The symbolic (not localizable) command name, lower case. | ||
*/ | ||
static const char* symbol() | ||
{ | ||
return "subscribe-block"; | ||
} | ||
|
||
|
||
/** | ||
* The member symbolic (not localizable) command name, lower case. | ||
*/ | ||
virtual const char* name() | ||
{ | ||
return subscribe_block::symbol(); | ||
} | ||
|
||
/** | ||
* The localizable command category name, upper case. | ||
*/ | ||
virtual const char* category() | ||
{ | ||
return "ONLINE"; | ||
} | ||
|
||
/** | ||
* The localizable command description. | ||
*/ | ||
virtual const char* description() | ||
{ | ||
return "Watch the network for all blocks. Requires a Libbitcoin server connection."; | ||
} | ||
|
||
/** | ||
* Load program argument definitions. | ||
* A value of -1 indicates that the number of instances is unlimited. | ||
* @return The loaded program argument definitions. | ||
*/ | ||
virtual arguments_metadata& load_arguments() | ||
{ | ||
return get_argument_metadata() | ||
.add("server-url", 1); | ||
} | ||
|
||
/** | ||
* Load parameter fallbacks from file or input as appropriate. | ||
* @param[in] input The input stream for loading the parameters. | ||
* @param[in] The loaded variables. | ||
*/ | ||
virtual void load_fallbacks(std::istream& input, | ||
po::variables_map& variables) | ||
{ | ||
} | ||
|
||
/** | ||
* Load program option definitions. | ||
* BUGBUG: see boost bug/fix: svn.boost.org/trac/boost/ticket/8009 | ||
* @return The loaded program option definitions. | ||
*/ | ||
virtual options_metadata& load_options() | ||
{ | ||
using namespace po; | ||
options_description& options = get_option_metadata(); | ||
options.add_options() | ||
( | ||
BX_HELP_VARIABLE ",h", | ||
value<bool>()->zero_tokens(), | ||
"Get a description and instructions for this command." | ||
) | ||
( | ||
BX_CONFIG_VARIABLE ",c", | ||
value<boost::filesystem::path>(), | ||
"The path to the configuration settings file." | ||
) | ||
( | ||
"duration,d", | ||
value<uint32_t>(&option_.duration)->default_value(600), | ||
"The duration of the subscription in seconds, defaults to 600." | ||
) | ||
( | ||
"format,f", | ||
value<explorer::config::encoding>(&option_.format), | ||
"The output format. Options are 'info', 'json' and 'xml', defaults to 'info'." | ||
) | ||
( | ||
"server-url", | ||
value<std::string>(&argument_.server_url), | ||
"The URL of the Libbitcoin server to use. If not specified the URL is obtained from configuration settings or defaults." | ||
); | ||
|
||
return options; | ||
} | ||
|
||
/** | ||
* Set variable defaults from configuration variable values. | ||
* @param[in] variables The loaded variables. | ||
*/ | ||
virtual void set_defaults_from_config(po::variables_map& variables) | ||
{ | ||
} | ||
|
||
/** | ||
* Invoke the command. | ||
* @param[out] output The input stream for the command execution. | ||
* @param[out] error The input stream for the command execution. | ||
* @return The appropriate console return code { -1, 0, 1 }. | ||
*/ | ||
virtual console_result invoke(std::ostream& output, | ||
std::ostream& cerr); | ||
|
||
/* Properties */ | ||
|
||
/** | ||
* Get the value of the server-url argument. | ||
*/ | ||
virtual std::string& get_server_url_argument() | ||
{ | ||
return argument_.server_url; | ||
} | ||
|
||
/** | ||
* Set the value of the server-url argument. | ||
*/ | ||
virtual void set_server_url_argument( | ||
const std::string& value) | ||
{ | ||
argument_.server_url = value; | ||
} | ||
|
||
/** | ||
* Get the value of the duration option. | ||
*/ | ||
virtual uint32_t& get_duration_option() | ||
{ | ||
return option_.duration; | ||
} | ||
|
||
/** | ||
* Set the value of the duration option. | ||
*/ | ||
virtual void set_duration_option( | ||
const uint32_t& value) | ||
{ | ||
option_.duration = value; | ||
} | ||
|
||
/** | ||
* Get the value of the format option. | ||
*/ | ||
virtual explorer::config::encoding& get_format_option() | ||
{ | ||
return option_.format; | ||
} | ||
|
||
/** | ||
* Set the value of the format option. | ||
*/ | ||
virtual void set_format_option( | ||
const explorer::config::encoding& value) | ||
{ | ||
option_.format = value; | ||
} | ||
|
||
private: | ||
|
||
/** | ||
* Command line argument bound variables. | ||
* Uses cross-compiler safe constructor-based zeroize. | ||
* Zeroize for unit test consistency with program_options initialization. | ||
*/ | ||
struct argument | ||
{ | ||
argument() | ||
: server_url() | ||
{ | ||
} | ||
|
||
std::string server_url; | ||
} argument_; | ||
|
||
/** | ||
* Command line option bound variables. | ||
* Uses cross-compiler safe constructor-based zeroize. | ||
* Zeroize for unit test consistency with program_options initialization. | ||
*/ | ||
struct option | ||
{ | ||
option() | ||
: duration(), | ||
format() | ||
{ | ||
} | ||
|
||
uint32_t duration; | ||
explorer::config::encoding format; | ||
} option_; | ||
}; | ||
|
||
} // namespace commands | ||
} // namespace explorer | ||
} // namespace libbitcoin | ||
|
||
#endif |
Oops, something went wrong.