Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
2#include <iostream>
3#include <boost/exception/diagnostic_information.hpp>
4
5struct database { };
6
7namespace bpo = boost::program_options;
8
9using bpo::options_description;
10using bpo::variables_map;
11using std::string;
12using std::vector;
13
14class chain_plugin : public appbase::plugin<chain_plugin>
15{
16 public:
18
19 virtual void set_program_options( options_description& cli, options_description& cfg ) override
20 {
21 cfg.add_options()
22 ("readonly", "open the database in read only mode")
23 ("dbsize", bpo::value<uint64_t>()->default_value( 8*1024 ), "Minimum size MB of database shared memory file")
24 ;
25 cli.add_options()
26 ("replay", "clear chain database and replay all blocks" )
27 ("reset", "clear chain database and block log" )
28 ;
29 }
30
31 void plugin_initialize( const variables_map& options ) { std::cout << "initialize chain plugin\n"; }
32 void plugin_startup() { std::cout << "starting chain plugin \n"; }
33 void plugin_shutdown() { std::cout << "shutdown chain plugin \n"; }
34
35 database& db() { return _db; }
36
37 private:
38 database _db;
39};
40
41class net_plugin : public appbase::plugin<net_plugin>
42{
43 public:
46
48
49 virtual void set_program_options( options_description& cli, options_description& cfg ) override
50 {
51 cfg.add_options()
52 ("listen-endpoint", bpo::value<string>()->default_value( "127.0.0.1:9876" ), "The local IP address and port to listen for incoming connections.")
53 ("remote-endpoint", bpo::value< vector<string> >()->composing(), "The IP address and port of a remote peer to sync with.")
54 ("public-endpoint", bpo::value<string>()->default_value( "0.0.0.0:9876" ), "The public IP address and port that should be advertized to peers.")
55 ;
56 }
57
58 void plugin_initialize( const variables_map& options ) { std::cout << "initialize net plugin\n"; }
59 void plugin_startup() { std::cout << "starting net plugin \n"; }
60 void plugin_shutdown() { std::cout << "shutdown net plugin \n"; }
61
62};
63
64
65
66int main( int argc, char** argv ) {
67 try {
69 if( !appbase::app().initialize( argc, argv ) )
70 return -1;
73 } catch ( const boost::exception& e ) {
74 std::cerr << boost::diagnostic_information(e) << "\n";
75 } catch ( const std::exception& e ) {
76 std::cerr << e.what() << "\n";
77 } catch ( ... ) {
78 std::cerr << "unknown exception\n";
79 }
80 std::cout << "exited cleanly\n";
81 return 0;
82}
void plugin_initialize(const variables_map &options)
Definition main.cpp:31
virtual void set_program_options(options_description &cli, options_description &cfg) override
Definition main.cpp:19
APPBASE_PLUGIN_REQUIRES()
void plugin_shutdown()
Definition main.cpp:33
database & db()
Definition main.cpp:35
void plugin_startup()
Definition main.cpp:32
void plugin_startup()
Definition main.cpp:59
void plugin_initialize(const variables_map &options)
Definition main.cpp:58
APPBASE_PLUGIN_REQUIRES((chain_plugin))
~net_plugin()
Definition main.cpp:45
void plugin_shutdown()
Definition main.cpp:60
virtual void set_program_options(options_description &cli, options_description &cfg) override
Definition main.cpp:49
net_plugin()
Definition main.cpp:44
char ** argv
application & app()
void cli()