Exemple #1
0
    def __init__(self, config):
        conf = DataStore.CONFIG_DEFAULTS
        args, argv = readconf.parse_argv([], conf)
        args.dbtype = config.get('database', 'type')
        if args.dbtype == 'sqlite3':
            args.connect_args = {
                'database': config.get('database', 'database')
            }
        elif args.dbtype == 'MySQLdb':
            args.connect_args = {
                'db': config.get('database', 'database'),
                'user': config.get('database', 'username'),
                'passwd': config.get('database', 'password')
            }
        elif args.dbtype == 'psycopg2':
            args.connect_args = {
                'database': config.get('database', 'database')
            }

        coin = config.get('server', 'coin')
        self.addrtype = 0
        if coin == 'litecoin':
            print_log('Litecoin settings:')
            datadir = config.get('server', 'datadir')
            print_log('  datadir = ' + datadir)
            args.datadir = [{
                "dirname": datadir,
                "chain": "Litecoin",
                "code3": "LTC",
                "address_version": "\u0030"
            }]
            print_log('  addrtype = 48')
            self.addrtype = 48

        DataStore.DataStore.__init__(self, args)

        # Use 1 (Bitcoin) if chain_id is not sent
        self.chain_id = self.datadirs[0]["chain_id"] or 1
        print_log('Coin chain_id = %d' % self.chain_id)

        self.sql_limit = int(config.get('database', 'limit'))

        self.tx_cache = {}
        self.bitcoind_url = 'http://%s:%s@%s:%s/' % (
            config.get('bitcoind', 'user'), config.get('bitcoind', 'password'),
            config.get('bitcoind', 'host'), config.get('bitcoind', 'port'))

        self.chunk_cache = {}

        self.address_queue = Queue()

        self.lock = threading.Lock()  # for the database
        self.cache_lock = threading.Lock()  # for the cache
        self.last_tx_id = 0
        self.known_mempool_hashes = []
    def __init__(self, config):
        conf = DataStore.CONFIG_DEFAULTS
        args, argv = readconf.parse_argv([], conf)
        args.dbtype = config.get('database', 'type')
        if args.dbtype == 'sqlite3':
            args.connect_args = {'database': config.get('database', 'database')}
        elif args.dbtype == 'MySQLdb':
            args.connect_args = {'db': config.get('database', 'database'), 'user': config.get('database', 'username'), 'passwd': config.get('database', 'password')}
        elif args.dbtype == 'psycopg2':
            args.connect_args = {'database': config.get('database', 'database')}

        coin = config.get('server', 'coin')
        self.addrtype = 0
        if coin == 'litecoin':
            print_log('Litecoin settings:')
            datadir = config.get('server', 'datadir')
            print_log('  datadir = ' + datadir)
            args.datadir = [{"dirname": datadir, "chain": "Litecoin", "code3": "LTC", "address_version": "\u0030"}]
            print_log('  addrtype = 48')
            self.addrtype = 48

        DataStore.DataStore.__init__(self, args)

        # Use 1 (Bitcoin) if chain_id is not sent
        self.chain_id = self.datadirs[0]["chain_id"] or 1
        print_log('Coin chain_id = %d' % self.chain_id)

        self.sql_limit = int(config.get('database', 'limit'))

        self.tx_cache = {}
        self.bitcoind_url = 'http://%s:%s@%s:%s/' % (config.get('bitcoind', 'user'), config.get('bitcoind', 'password'), config.get('bitcoind', 'host'), config.get('bitcoind', 'port'))

        self.chunk_cache = {}

        self.address_queue = Queue()

        self.lock = threading.Lock()        # for the database
        self.cache_lock = threading.Lock()  # for the cache
        self.last_tx_id = 0
        self.known_mempool_hashes = []
Exemple #3
0
def main(argv):
    if argv[0] == '--show-policy':
        for policy in argv[1:] or list_policies():
            show_policy(policy)
        return 0
    elif argv[0] == '--list-policies':
        print("Available chain policies:")
        for name in list_policies():
            print("  %s" % name)
        return 0

    args, argv = readconf.parse_argv(argv, create_conf())

    if not argv:
        pass
    elif argv[0] in ('-h', '--help'):
        print(
            """Usage: python -m Abe.abe [-h] [--config=FILE] [--CONFIGVAR=VALUE]...

A Bitcoin block chain browser.

  --help                    Show this help message and exit.
  --version                 Show the program version and exit.
  --print-htdocs-directory  Show the static content directory name and exit.
  --list-policies           Show the available policy names for --datadir.
  --show-policy POLICY...   Describe the given policy.
  --query /q/COMMAND        Show the given URI content and exit.
  --config FILE             Read options from FILE.

All configuration variables may be given as command arguments.
See abe.conf for commented examples.""")
        return 0
    elif argv[0] in ('-v', '--version'):
        print ABE_APPNAME, ABE_VERSION
        print "Schema version", DataStore.SCHEMA_VERSION
        return 0
    elif argv[0] == '--print-htdocs-directory':
        print find_htdocs()
        return 0
    else:
        sys.stderr.write(
            "Error: unknown option `%s'\n"
            "See `python -m Abe.abe --help' for more information.\n" %
            (argv[0], ))
        return 1

    logging.basicConfig(
        stream=sys.stdout,
        level=logging.DEBUG if args.query is None else logging.ERROR,
        format=DEFAULT_LOG_FORMAT)
    if args.logging is not None:
        import logging.config as logging_config
        logging_config.dictConfig(args.logging)

    # Set timezone
    if args.timezone:
        os.environ['TZ'] = args.timezone

    if args.auto_agpl:
        import tarfile

    # --rpc-load-mempool loops forever, make sure it's used with
    # --no-load/--no-serve so users know the implications
    if args.rpc_load_mempool and not (args.no_load or args.no_serve):
        sys.stderr.write("Error: --rpc-load-mempool requires --no-serve\n")
        return 1

    store = make_store(args)
    export_store_to_csv(store)
    if (not args.no_serve):
        #serve(store)
        pass
    return 0
Exemple #4
0
        "base_url": None,
        "no_update": None,
        "pidfile": '',
        "access_log": '',
        "error_log": '',
        "document_root": '',
        "template": AML_TEMPLATE,
        "template_vars": {
            "APPNAME": AML_APPNAME,
            "CONTENT_TYPE": 'text/html',
        },
    }

    conf.update(DataStore.CONFIG_DEFAULTS)
    argv.append('--config=/etc/abe.conf')
    args, argv = readconf.parse_argv(argv, conf)
    if argv:
        sys.stderr.write("Error: unknown option `%s'\n" % (argv[0], ))
        sys.exit(1)

    daemon = MyDaemon(args)
    if cmd == 'start':
        daemon.start()
    elif cmd == 'stop':
        daemon.stop()
    elif cmd == 'restart':
        daemon.restart()
    elif cmd == 'run':
        daemon.stop()
        daemon.run()
Exemple #5
0
        "base_url":     None,
        "no_update":    None,
        "pidfile":      '',
        "access_log":   '',
        "error_log":    '',
        "document_root":'',
        "template":     AML_TEMPLATE,
        "template_vars": {
            "APPNAME": AML_APPNAME,
            "CONTENT_TYPE": 'text/html',
            },
        }

    conf.update(DataStore.CONFIG_DEFAULTS)
    argv.append('--config=/etc/abe.conf')
    args, argv = readconf.parse_argv(argv, conf)
    if argv:
        sys.stderr.write("Error: unknown option `%s'\n" % (argv[0],))
        sys.exit(1)

    daemon = MyDaemon(args)
    if cmd == 'start' :
        daemon.start()
    elif cmd == 'stop' :
        daemon.stop()
    elif cmd == 'restart' :
        daemon.restart()
    elif cmd=='run':
        daemon.stop()
        daemon.run()