Exemplo n.º 1
0
    def run_tests_for_chain(self, chain):

        block_gen_params = [chain, env_config.rpccaller_for_chain(chain)]
        block_gen_params.extend(
            env_config.AVAILABLE_CHAINS[chain]['proc']['block_gen'])
        self.block_generator = BlockGenerator(*block_gen_params)

        tx_gen_params = [chain, env_config.rpccaller_for_chain(chain)]
        tx_gen_params.extend(
            env_config.AVAILABLE_CHAINS[chain]['proc']['tx_gen'])
        self.tx_generator = TxGenerator(*tx_gen_params)

        greedy_cacher_params = [
            chain,
            env_config.rpccaller_for_chain(chain), self.DB_CLIENT
        ]
        greedy_cacher_params.extend(
            env_config.AVAILABLE_CHAINS[chain]['proc']['greedy_cacher'])
        self.greedy_cacher = GreedyCacher(*greedy_cacher_params,
                                          wait_time_greedy=0)

        reorg_cron_params = [
            chain,
            env_config.rpccaller_for_chain(chain), self.DB_CLIENT
        ]
        reorg_cron_params.extend(
            env_config.AVAILABLE_CHAINS[chain]['proc']['reorg_cron'])
        self.daemon_reorg_cron = DaemonReorgManager(*reorg_cron_params)

        if self.needs_101(chain):
            self.do_101(chain)

        self.greedy_cacher._cron_loop()

        for i in xrange(5):
            for j in xrange(5):
                self.tx_generator._cron_loop()
            self.block_generator._cron_loop()

        # Shouldn't cache anything else because greedy_cacher doesn't handle tip changes
        self.greedy_cacher._cron_loop()

        self.daemon_reorg_cron._cron_loop()

        # After calling reorg cron, it should cache more things again
        self.greedy_cacher._cron_loop()
Exemplo n.º 2
0
    def update_chain(self, request_data):
        self.chain = None
        if request_data and 'chain' in request_data:
            self.chain = request_data['chain']
            del request_data['chain']
        else:
            self.chain = env_config.DEFAULT_CHAIN
        if not self.chain in env_config.AVAILABLE_CHAINS:
            raise UnknownChainError

        ormin_form.set_namespace(self.chain)
        self.rpccaller = env_config.rpccaller_for_chain(self.chain)
        RpcCachedModel.set_rpccaller(self.rpccaller)

        return request_data
Exemplo n.º 3
0
    argv = gflags.FLAGS(sys.argv)
except gflags.FlagsError, e:
    print('%s\n\nUsage %s ARGS \n%s' % (e, sys.argv[0], gflags.FLAGS))
    sys.exit(0)
FLAGS = gflags.FLAGS

# ===----------------------------------------------------------------------===

import time

from explorer.process.mempoolsaver import MempoolSaver
from explorer.process.mempoolstats import MempoolStatsCacher

from explorer import env_config

chain = FLAGS.chain

# Wait for db to start
time.sleep(12)

mempool_cacher_params = [chain, env_config.rpccaller_for_chain(chain), env_config.DB_FACTORY.create()]
mempool_cacher_params.extend(env_config.AVAILABLE_CHAINS[chain]['proc']['mempool_cacher'])
mempool_cacher = MempoolStatsCacher(*mempool_cacher_params)
mempool_cacher.start()

if 'mempool_saver' in env_config.AVAILABLE_CHAINS[chain]:
    mempool_saver_params = [chain, env_config.rpccaller_for_chain(chain)]
    mempool_saver_params.extend(env_config.AVAILABLE_CHAINS[chain]['proc']['mempool_saver'])
    mempool_saver = MempoolSaver(*mempool_saver_params)
    mempool_saver.start()
Exemplo n.º 4
0
import gflags

gflags.DEFINE_string('chain', u"bitcoin",
                     u"Chain to greedy cache for")

try:
    import sys
    argv = gflags.FLAGS(sys.argv)
except gflags.FlagsError, e:
    print('%s\n\nUsage %s ARGS \n%s' % (e, sys.argv[0], gflags.FLAGS))
    sys.exit(0)
FLAGS = gflags.FLAGS

# ===----------------------------------------------------------------------===

import time

from explorer import env_config
from explorer.process.greedy import GreedyCacher

chain = FLAGS.chain

# Wait for db to start
time.sleep(12)

greedy_cacher_params = [chain, env_config.rpccaller_for_chain(chain), env_config.DB_FACTORY.create()]
greedy_cacher_params.extend(env_config.AVAILABLE_CHAINS[chain]['proc']['greedy_cacher'])
greedy_cacher = GreedyCacher(*greedy_cacher_params)
greedy_cacher.start()
Exemplo n.º 5
0
import gflags

gflags.DEFINE_string('chain', u"bitcoin",
                     u"Chain to manage reorgs for")

try:
    import sys
    argv = gflags.FLAGS(sys.argv)
except gflags.FlagsError, e:
    print('%s\n\nUsage %s ARGS \n%s' % (e, sys.argv[0], gflags.FLAGS))
    sys.exit(0)
FLAGS = gflags.FLAGS

# ===----------------------------------------------------------------------===

import time

from explorer import env_config
from explorer.process.subscriber import DaemonReorgManager

chain = FLAGS.chain

# Wait for db to start
time.sleep(12)

reorg_cron_params = [chain, env_config.rpccaller_for_chain(chain), env_config.DB_FACTORY.create()]
reorg_cron_params.extend(env_config.AVAILABLE_CHAINS[chain]['proc']['reorg_cron'])
daemon_reorg_cron = DaemonReorgManager(*reorg_cron_params)
daemon_reorg_cron.start()
Exemplo n.º 6
0
    print('%s\n\nUsage %s ARGS \n%s' % (e, sys.argv[0], gflags.FLAGS))
    sys.exit(0)
FLAGS = gflags.FLAGS

# ===----------------------------------------------------------------------===

from explorer import env_config
from explorer.process.generator.block import BlockGenerator
from explorer.process.generator.pegin import PeginGenerator
from explorer.process.generator.pegout import PegoutGenerator
from explorer.process.generator.transaction import TxGenerator

chain = FLAGS.chain

if 'block_gen' in env_config.AVAILABLE_CHAINS[chain]['proc']:
    block_gen_params = [chain, env_config.rpccaller_for_chain(chain)]
    block_gen_params.extend(
        env_config.AVAILABLE_CHAINS[chain]['proc']['block_gen'])
    block_generator = BlockGenerator(*block_gen_params)
    block_generator.start()

if 'tx_gen' in env_config.AVAILABLE_CHAINS[chain]['proc']:
    tx_gen_params = [chain, env_config.rpccaller_for_chain(chain)]
    tx_gen_params.extend(env_config.AVAILABLE_CHAINS[chain]['proc']['tx_gen'])
    tx_generator = TxGenerator(*tx_gen_params)
    tx_generator.start()

if 'pegin_gen' in env_config.AVAILABLE_CHAINS[chain][
        'proc'] and 'parent_chain' in env_config.AVAILABLE_CHAINS[chain][
            'properties']:
    parent_chain_rpccaller = env_config.rpccaller_for_chain(
Exemplo n.º 7
0
gflags.DEFINE_string('chain', u"bitcoin", u"Chain to subscribe to")

try:
    import sys
    argv = gflags.FLAGS(sys.argv)
except gflags.FlagsError, e:
    print('%s\n\nUsage %s ARGS \n%s' % (e, sys.argv[0], gflags.FLAGS))
    sys.exit(0)
FLAGS = gflags.FLAGS

# ===----------------------------------------------------------------------===

import time

from explorer import env_config
from explorer.process.subscriber import DaemonSubscriber

chain = FLAGS.chain

# Wait for db to start
time.sleep(12)

daemon_subscriber = DaemonSubscriber(
    env_config.node_zmq_for_chain(chain),
    chain,
    env_config.rpccaller_for_chain(chain),
    env_config.DB_FACTORY,
    cache_stats=env_config.AVAILABLE_CHAINS[chain]['properties']
    ['stats_support'])
daemon_subscriber.start()
Exemplo n.º 8
0
 def do_101(self, chain):
     block_hashes = env_config.rpccaller_for_chain(chain).RpcCall(
         'generate', {'nblocks': 101})