1 from service import MiningService
2 from subscription import MiningSubscription
3 from twisted.internet import defer
7 '''Setup mining service internal environment.
8 You should not need to change this. If you
9 want to use another Worker manager or Share manager,
10 you should set proper reference to Interfaces class
11 *before* you call setup() in the launcher script.'''
13 from stratum import settings
14 from interfaces import Interfaces
16 # Let's wait until share manager and worker manager boot up
17 (yield Interfaces.share_manager.on_load)
18 (yield Interfaces.worker_manager.on_load)
20 from lib.block_updater import BlockUpdater
21 from lib.template_registry import TemplateRegistry
22 from lib.bitcoin_rpc import BitcoinRPC
23 from lib.block_template import BlockTemplate
24 from lib.coinbaser import SimpleCoinbaser
26 bitcoin_rpc = BitcoinRPC(settings.BITCOIN_TRUSTED_HOST,
27 settings.BITCOIN_TRUSTED_PORT,
28 settings.BITCOIN_TRUSTED_USER,
29 settings.BITCOIN_TRUSTED_PASSWORD)
31 coinbaser = SimpleCoinbaser(bitcoin_rpc, settings.CENTRAL_WALLET)
32 (yield coinbaser.on_load)
34 registry = TemplateRegistry(BlockTemplate,
38 MiningSubscription.on_block)
40 # Template registry is the main interface between Stratum service
42 Interfaces.set_template_registry(registry)
44 # Set up polling mechanism for detecting new block on the network
45 # This is just failsafe solution when -blocknotify
46 # mechanism is not working properly
47 BlockUpdater(registry, bitcoin_rpc)
50 log = stratum.logger.get_logger('mining')
51 log.info("MINING SERVICE IS READY")
52 on_startup.callback(True)