def main(argv): conf = { "debug": None, "logging": None, } conf.update(DataStore.CONFIG_DEFAULTS) args, argv = readconf.parse_argv(argv, conf, strict=False) if argv and argv[0] in ('-h', '--help'): print( """Usage: python -m Abe.reconfigure [-h] [--config=FILE] [--CONFIGVAR=VALUE]... Apply configuration changes to an existing Abe database, if possible. --help Show this help message and exit. --config FILE Read options from FILE. --use-firstbits {true|false} Turn Firstbits support on or off. --keep-scriptsig false Remove input validation scripts from the database. All configuration variables may be given as command arguments.""") return 0 logging.basicConfig(stream=sys.stdout, level=logging.DEBUG, format="%(message)s") if args.logging is not None: import logging.config as logging_config logging_config.dictConfig(args.logging) store = DataStore.new(args) firstbits.reconfigure(store, args) keep_scriptsig_reconfigure(store, args) return 0
def main(argv): conf = { "debug": None, "logging": None, } conf.update(DataStore.CONFIG_DEFAULTS) args, argv = readconf.parse_argv(argv, conf, strict=False) if argv and argv[0] in ('-h', '--help'): print ("""Usage: python -m Abe.admin [-h] [--config=FILE] COMMAND... Options: --help Show this help message and exit. --config FILE Abe configuration file. Commands: delete-chain-blocks NAME Delete all blocks in the specified chain from the database. delete-chain-transactions NAME Delete all blocks and transactions in the specified chain. delete-tx TX_ID Delete the specified transaction. delete-tx TX_HASH link-txin Link transaction inputs to previous outputs. rewind-datadir DIRNAME Reset the pointer to force a rescan of blockfiles in DIRNAME.""") return 0 logging.basicConfig( stream=sys.stdout, level=logging.DEBUG, format="%(message)s") if args.logging is not None: import logging.config as logging_config logging_config.dictConfig(args.logging) store = DataStore.new(args) while len(argv) != 0: command = argv.pop(0) if command == 'delete-chain-blocks': delete_chain_blocks(store, argv.pop(0)) elif command == 'delete-chain-transactions': delete_chain_transactions(store, argv.pop(0)) elif command == 'delete-tx': delete_tx(store, argv.pop(0)) elif command == 'rewind-datadir': rewind_datadir(store, argv.pop(0)) elif command == 'link-txin': link_txin(store) else: raise ValueError("Unknown command: " + command) return 0
def main(argv): conf = {"debug": None, "logging": None} conf.update(DataStore.CONFIG_DEFAULTS) args, argv = readconf.parse_argv(argv, conf, strict=False) if argv and argv[0] in ("-h", "--help"): print( """Usage: python -m Abe.reconfigure [-h] [--config=FILE] [--CONFIGVAR=VALUE]... Apply configuration changes to an existing Abe database, if possible. --help Show this help message and exit. --config FILE Read options from FILE. --use-firstbits {true|false} Turn Firstbits support on or off. --keep-scriptsig false Remove input validation scripts from the database. All configuration variables may be given as command arguments.""" ) return 0 logging.basicConfig(stream=sys.stdout, level=logging.DEBUG, format="%(message)s") if args.logging is not None: import logging.config as logging_config logging_config.dictConfig(args.logging) store = DataStore.new(args) firstbits.reconfigure(store, args) keep_scriptsig_reconfigure(store, args) return 0
def main(argv): conf = { "debug": None, "logging": None, } conf.update(DataStore.CONFIG_DEFAULTS) args, argv = readconf.parse_argv(argv, conf, strict=False) if argv and argv[0] in ('-h', '--help'): print("""Usage: python -m Abe.admin [-h] [--config=FILE] COMMAND... Options: --help Show this help message and exit. --config FILE Abe configuration file. Commands: delete-chain-blocks NAME Delete all blocks in the specified chain from the database. delete-chain-transactions NAME Delete all blocks and transactions in the specified chain. delete-tx TX_ID Delete the specified transaction. delete-tx TX_HASH link-txin Link transaction inputs to previous outputs. rewind-datadir DIRNAME Reset the pointer to force a rescan of blockfiles in DIRNAME.""") return 0 logging.basicConfig(stream=sys.stdout, level=logging.DEBUG, format="%(message)s") if args.logging is not None: import logging.config as logging_config logging_config.dictConfig(args.logging) store = DataStore.new(args) while len(argv) != 0: command = argv.pop(0) if command == 'delete-chain-blocks': delete_chain_blocks(store, argv.pop(0)) elif command == 'delete-chain-transactions': delete_chain_transactions(store, argv.pop(0)) elif command == 'delete-tx': delete_tx(store, argv.pop(0)) elif command == 'rewind-datadir': rewind_datadir(store, argv.pop(0)) elif command == 'link-txin': link_txin(store) else: raise ValueError("Unknown command: " + command) return 0
def main(argv): logging.basicConfig(level=logging.DEBUG) args, argv = readconf.parse_argv(argv, DataStore.CONFIG_DEFAULTS, strict=False) if argv and argv[0] in ('-h', '--help'): print "Usage: verify.py --dbtype=MODULE --connect-args=ARGS" return 0 store = DataStore.new(args) logger = logging.getLogger("verify") checked, bad = 0, 0 for (chain_id,) in store.selectall(""" SELECT chain_id FROM chain"""): logger.info("checking chain %d", chain_id) checked1, bad1 = verify_tx_merkle_hashes(store, logger, chain_id) checked += checked1 bad += bad1 logger.info("All chains: %d Merkle trees, %d bad", checked, bad) return bad and 1
def main(argv): conf = { "debug": None, "logging": None, "count": 200, "seed": 1, "blkfile": None, } conf.update(DataStore.CONFIG_DEFAULTS) args, argv = readconf.parse_argv(argv, conf, strict=False) if argv and argv[0] in ('-h', '--help'): print ("""Usage: python -m Abe.mixup [-h] [--config=FILE] [--CONFIGVAR=VALUE]... Load blocks out of order. --help Show this help message and exit. --config FILE Read options from FILE. --count NUMBER Load COUNT blocks. --blkfile FILE Load the first COUNT blocks from FILE. --seed NUMBER Random seed (not implemented; 0=file order). All configuration variables may be given as command arguments.""") return 0 if args.blkfile is None: raise ValueError("--blkfile is required.") logging.basicConfig( stream=sys.stdout, level=logging.DEBUG, format="%(message)s") if args.logging is not None: import logging.config as logging_config logging_config.dictConfig(args.logging) store = DataStore.new(args) ds = BCDataStream.BCDataStream() file = open(args.blkfile, "rb") ds.map_file(file, 0) file.close() mixup_blocks(store, ds, int(args.count), None, int(args.seed or 0)) return 0
def init(self): import DataStore, readconf, logging, sys self.conf.update({ "debug": None, "logging": None }) self.conf.update(DataStore.CONFIG_DEFAULTS) args, argv = readconf.parse_argv(self.argv, self.conf, strict=False) if argv and argv[0] in ('-h', '--help'): print self.usage() return None, [] logging.basicConfig( stream=sys.stdout, level=logging.DEBUG, format="%(message)s") if args.logging is not None: import logging.config as logging_config logging_config.dictConfig(args.logging) store = DataStore.new(args) return store, argv
def main(argv): conf = { "debug": None, "logging": None, "count": 200, "seed": 1, "blkfile": None, } conf.update(DataStore.CONFIG_DEFAULTS) args, argv = readconf.parse_argv(argv, conf, strict=False) if argv and argv[0] in ('-h', '--help'): print( """Usage: python -m Abe.mixup [-h] [--config=FILE] [--CONFIGVAR=VALUE]... Load blocks out of order. --help Show this help message and exit. --config FILE Read options from FILE. --count NUMBER Load COUNT blocks. --blkfile FILE Load the first COUNT blocks from FILE. --seed NUMBER Random seed (not implemented; 0=file order). All configuration variables may be given as command arguments.""") return 0 if args.blkfile is None: raise ValueError("--blkfile is required.") logging.basicConfig(stream=sys.stdout, level=logging.DEBUG, format="%(message)s") if args.logging is not None: import logging.config as logging_config logging_config.dictConfig(args.logging) store = DataStore.new(args) ds = BCDataStream.BCDataStream() file = open(args.blkfile, "rb") ds.map_file(file, 0) file.close() mixup_blocks(store, ds, int(args.count), None, int(args.seed or 0)) return 0
def main(argv): logging.basicConfig(level=logging.DEBUG) args, argv = readconf.parse_argv(argv, DataStore.CONFIG_DEFAULTS, strict=False) if argv and argv[0] in ('-h', '--help'): print "Usage: verify.py --dbtype=MODULE --connect-args=ARGS" return 0 store = DataStore.new(args) logger = logging.getLogger("verify") checked, bad = 0, 0 for (chain_id, ) in store.selectall(""" SELECT chain_id FROM chain"""): logger.info("checking chain %d", chain_id) checked1, bad1 = verify_tx_merkle_hashes(store, logger, chain_id) checked += checked1 bad += bad1 logger.info("All chains: %d Merkle trees, %d bad", checked, bad) return bad and 1
def main(argv): if len(argv) == 0: print ("""\nUsage: python3 -m adapter config-file.ini ( stop | daemon ) """ + adapter_app +""", version """ + adapter_version +""" config-file Configuration file, see mcfeedadapter_example.conf for examples. action Optional, one of the following: stop Stop running adapter daemon Start adapter as daemon """) return 0 print (adapter_app + """, version """ + adapter_version + "\n") print ("") args=readconf.parse_argv(argv) if cfg.action is not None: if cfg.action == 'daemon': utils.become_daemon(); if not readconf.read_conf(args): return 1; if not initialize_outputs(): close_outputs() return 1; current_pid=utils.file_read(cfg.pid_file) if cfg.action is not None: if (cfg.action == 'stop') or (cfg.action == 'status'): if current_pid is None: print("Adapter is not running\n") return 0 process_id=int(current_pid) print("Adapter found, PID " + str(process_id)) if cfg.action == 'stop': utils.remove_file(cfg.pid_file) while utils.is_process_running(process_id): time.sleep(0.05) print("Adapter stopped\n") return 0 if current_pid is not None: utils.print_error("Adapter for this feed is already running") return 1 utils.file_write(cfg.pid_file,utils.get_pid()) signal.signal(signal.SIGINT,term_signal_handler) signal.signal(signal.SIGTERM,term_signal_handler) current_pid=utils.file_read(cfg.pid_file) utils.log_write("Adapter started, PID: " + str(current_pid)) while current_pid is not None: iteration_result=adapter_iteration() if cfg.action is not None: if cfg.action == 'term': utils.remove_file(cfg.pid_file) current_pid = None if current_pid is not None: if not iteration_result[0]: utils.print_error("Adapter encountered error when processing feed records and will be stopped") utils.remove_file(cfg.pid_file) return 1 if not iteration_result[1]: time.sleep(0.1) current_pid=utils.file_read(cfg.pid_file) close_outputs() utils.log_write("Adapter stopped")