def main(): args = sys.argv[1:] args += os.getenv('CONTRACT_FILE', '').split(' ') args += os.getenv('CONTRACT_ARGS', '').split(' ') args = list(filter(None, args)) if len(args) < 2: # must provide file name and arguments print("WARN! No smart contracts args... skip") return settings.setup_privnet(True) settings.set_log_smart_contract_events(True) # Instantiate the blockchain and subscribe to notifications blockchain = LevelDBBlockchain(settings.chain_leveldb_path) Blockchain.RegisterBlockchain(blockchain) app = ImportSC(args, blockchain, reactor) # Try to set up a notification db if NotificationDB.instance(): NotificationDB.instance().start() reactor.callInThread(app.worker) NodeLeader.Instance().Start() reactor.run() NotificationDB.close() Blockchain.Default().Dispose() NodeLeader.Instance().Shutdown()
def main(): settings.setup('protocol.coz.json') # Setup the blockchain blockchain = LevelDBBlockchain(settings.LEVELDB_PATH) Blockchain.RegisterBlockchain(blockchain) dbloop = task.LoopingCall(Blockchain.Default().PersistBlocks) dbloop.start(.1) NodeLeader.Instance().Start() # Disable smart contract events for external smart contracts settings.set_log_smart_contract_events(False) global Wallet Wallet = UserWallet.Open(path="infinitewallet", password="******") logger.info("Created the Wallet") logger.info(Wallet.AddressVersion) walletdb_loop = task.LoopingCall(Wallet.ProcessBlocks) walletdb_loop.start(1) #Wallet.CreateKey(KeyPair.PrivateKeyFromWIF(wif)) # Start a thread with custom code d = threading.Thread(target=custom_background_code) d.setDaemon(True) # daemonizing the thread will kill it when the main thread is quit d.start() # Run all the things (blocking call) logger.info("Everything setup and running. Waiting for events...") reactor.run() logger.info("Shutting down.")
def main(): # Setup the blockchain blockchain = LevelDBBlockchain(settings.LEVELDB_PATH) Blockchain.RegisterBlockchain(blockchain) dbloop = task.LoopingCall(Blockchain.Default().PersistBlocks) dbloop.start(.1) NodeLeader.Instance().Start() # Disable smart contract events for external smart contracts settings.set_log_smart_contract_events(False) # Start a thread with custom code d = threading.Thread(target=custom_background_code) d.setDaemon(True) # daemonizing the thread will kill it when the main thread is quit d.start() # Hook up Klein API to Twisted reactor endpoint_description = "tcp:port=%s:interface=localhost" % API_PORT endpoint = endpoints.serverFromString(reactor, endpoint_description) endpoint.listen(Site(app.resource())) # Run all the things (blocking call) logger.info("Everything setup and running. Waiting for events...") reactor.run() logger.info("Shutting down.")
def setUpClass(self): if os.path.exists(self.FIXTURE_FILENAME): print("fixtures already downloaded") else: print("downloading fixture block database. this may take a while") response = requests.get(self.FIXTURE_REMOTE_LOC, stream=True) response.raise_for_status() with open(self.FIXTURE_FILENAME, 'wb+') as handle: for block in response.iter_content(1024): handle.write(block) print("opening tar file") try: tar = tarfile.open(self.FIXTURE_FILENAME) tar.extractall() tar.close() print("extracted tar file") except Exception as e: print("Could not extract tar file %s " % e) if os.path.exists(self.leveldb_testpath()): print('loading blockchain') self._blockchain = TestLevelDBBlockchain( path=self.leveldb_testpath()) Blockchain.RegisterBlockchain(self._blockchain) print("Starting Tests") else: print("Error downloading fixtures")
def main(): conn = psycopg2.connect(connection_str) cursor = conn.cursor() ip_dict = getIpAddressMap(cursor) cursor.close() conn.close() # Use Custom config settings.setup("./config.json") settings.set_max_peers(500) # Setup the blockchain blockchain = LevelDBBlockchain(settings.chain_leveldb_path) Blockchain.RegisterBlockchain(blockchain) dbloop = task.LoopingCall(Blockchain.Default().PersistBlocks) dbloop.start(.1) NodeLeader.Instance().Start() # Start a thread with custom code d = threading.Thread(target=custom_background_code, args=(connection_str, ip_dict,)) d.setDaemon(True) # daemonizing the thread will kill it when the main thread is quit d.start() # Run all the things (blocking call) reactor.run() logger.info("Shutting down.")
def setUpClass(cls): settings.setup_unittest_net() Blockchain.DeregisterBlockchain() cls._blockchain = Blockchain(getBlockchainDB(cls.LEVELDB_TESTPATH), skip_version_check=True) Blockchain.RegisterBlockchain(cls._blockchain) cls._genesis = Blockchain.GenesisBlock()
def main(): # Use PrivateNet settings.setup_privnet() # Setup the blockchain blockchain = LevelDBBlockchain(settings.chain_leveldb_path) Blockchain.RegisterBlockchain(blockchain) dbloop = task.LoopingCall(Blockchain.Default().PersistBlocks) dbloop.start(.1) NodeLeader.Instance().Start() # Disable smart contract events for external smart contracts settings.set_log_smart_contract_events(False) # Start a thread with custom code d = threading.Thread(target=custom_background_code) d.setDaemon( True ) # daemonizing the thread will kill it when the main thread is quit d.start() # Run all the things (blocking call) logger.info("Everything setup and running. Waiting for events...") reactor.run() logger.info("Shutting down.")
def setUpClass(cls): Blockchain.DeregisterBlockchain() os.makedirs(cls.LEVELDB_TESTPATH, exist_ok=True) cls._blockchain = Blockchain(getBlockchainDB(cls.LEVELDB_TESTPATH), skip_version_check=True) Blockchain.RegisterBlockchain(cls._blockchain)
def start_neo(): # Use TestNet settings.setup_testnet() # Setup the blockchain blockchain = LevelDBBlockchain(settings.chain_leveldb_path) Blockchain.RegisterBlockchain(blockchain) dbloop = task.LoopingCall(Blockchain.Default().PersistBlocks) dbloop.start(.1) NodeLeader.Instance().Start() wallet = UserWallet.Open(path, to_aes_key(password)) # wallet.Rebuild() _walletdb_loop = task.LoopingCall(wallet.ProcessBlocks()) _walletdb_loop.start(.1) print("Opened wallet at %s" % path) # Start a thread with custom code d = threading.Thread(target=custom_background_code) d.setDaemon( True ) # daemonizing the thread will kill it when the main thread is quit d.start() # Run all the things (blocking call) reactor.run() logger.info("Shutting down.")
def setUpClass(cls): Blockchain.DeregisterBlockchain() super(BlockchainFixtureTestCase, cls).setUpClass() if not os.path.exists(cls.FIXTURE_FILENAME): print("downloading fixture block database. this may take a while") response = requests.get(cls.FIXTURE_REMOTE_LOC, stream=True) response.raise_for_status() with open(cls.FIXTURE_FILENAME, 'wb+') as handle: for block in response.iter_content(1024): handle.write(block) try: tar = tarfile.open(cls.FIXTURE_FILENAME) tar.extractall() tar.close() except Exception as e: raise Exception("Could not extract tar file - %s. You may want need to remove the fixtures file %s manually to fix this." % (e, cls.FIXTURE_FILENAME)) if not os.path.exists(cls.leveldb_testpath()): raise Exception("Error downloading fixtures") cls._blockchain = TestLevelDBBlockchain(path=cls.leveldb_testpath()) Blockchain.RegisterBlockchain(cls._blockchain)
def main(): parser = argparse.ArgumentParser() parser.add_argument("-c", "--config", action="store", help="Config file (default. %s)" % PROTOCOL_CONFIG, default=PROTOCOL_CONFIG) args = parser.parse_args() settings.setup(args.config) logger.info("Starting api.py") logger.info("Config: %s", args.config) logger.info("Network: %s", settings.net_name) # Setup the blockchain blockchain = LevelDBBlockchain(settings.LEVELDB_PATH) Blockchain.RegisterBlockchain(blockchain) dbloop = task.LoopingCall(Blockchain.Default().PersistBlocks) dbloop.start(.1) NodeLeader.Instance().Start() # Disable smart contract events for external smart contracts settings.set_log_smart_contract_events(False) # Start a thread with custom code d = threading.Thread(target=custom_background_code) d.setDaemon(True) # daemonizing the thread will kill it when the main thread is quit d.start() # Run all the things (blocking call) logger.info("Everything setup and running. Waiting for events...") reactor.run() logger.info("Shutting down.")
async def setup_and_start(loop): # Use TestNet settings.setup_privnet() # Setup the blockchain blockchain = LevelDBBlockchain(settings.chain_leveldb_path) Blockchain.RegisterBlockchain(blockchain) p2p = NetworkService() loop.create_task(p2p.start()) bg_task = loop.create_task(custom_background_code()) # Disable smart contract events for external smart contracts settings.set_log_smart_contract_events(False) app = web.Application() app.add_routes([ web.route('*', '/', home_route), web.get("/echo-get/{msg}", echo_msg), web.post("/echo-post/", echo_post), ]) runner = web.AppRunner(app) await runner.setup() site = web.TCPSite(runner, "0.0.0.0", API_PORT) await site.start() # Run all the things (blocking call) logger.info("Everything setup and running. Waiting for events...") return site
def main(): # Setup the blockchain settings.setup('protocol.faucet.json') blockchain = LevelDBBlockchain(settings.LEVELDB_PATH) Blockchain.RegisterBlockchain(blockchain) dbloop = task.LoopingCall(Blockchain.Default().PersistBlocks) dbloop.start(.1) NodeLeader.Instance().Start() # Start a thread with custom code # d = threading.Thread(target=custom_background_code) # d.setDaemon(True) # daemonizing the thread will kill it when the main thread is quit # d.start() # Run all the things (blocking call) #reactor.run() port = os.environ.get('FAUCET_PORT', 8080) host = os.environ.get('FAUCET_HOST', 'localhost') store = ItemStore() store.app.run(host, int(port)) logger.info("Shutting down.")
def main(): # Use TestNet settings.setup_testnet() # Instantiate the blockchain and subscribe to notifications blockchain = LevelDBBlockchain(settings.chain_leveldb_path) Blockchain.RegisterBlockchain(blockchain) # Try to set up a notification db if NotificationDB.instance(): NotificationDB.instance().start() # Start the prompt interface cli = MakeMultisig() # Run things # reactor.suggestThreadPoolSize(15) reactor.callInThread(cli.run) NodeLeader.Instance().Start() # reactor.run() is blocking, until `quit()` is called which stops the reactor. reactor.run() # After the reactor is stopped, gracefully shutdown the database. NotificationDB.close() Blockchain.Default().Dispose() NodeLeader.Instance().Shutdown()
def setUpClass(self): Blockchain.DeregisterBlockchain() os.makedirs(self.LEVELDB_TESTPATH, exist_ok=True) self._blockchain = LevelDBBlockchain(path=self.LEVELDB_TESTPATH, skip_version_check=True) Blockchain.RegisterBlockchain(self._blockchain)
def main(): parser = argparse.ArgumentParser() group = parser.add_mutually_exclusive_group() group.add_argument("-m", "--mainnet", action="store_true", default=False, help="Use MainNet instead of the default TestNet") group.add_argument("-p", "--privnet", action="store_true", default=False, help="Use PrivNet instead of the default TestNet") group.add_argument("--coznet", action="store_true", default=False, help="Use the CoZ network instead of the default TestNet") group.add_argument("-c", "--config", action="store", help="Use a specific config file") parser.add_argument("-t", "--set-default-theme", dest="theme", choices=["dark", "light"], help="Set the default theme to be loaded from the config file. Default: 'dark'") parser.add_argument("--version", action="version", version="neo-python v{version}".format(version=__version__)) args = parser.parse_args() # Setup depending on command line arguments. By default, the testnet settings are already loaded. if args.config: settings.setup(args.config) elif args.mainnet: settings.setup_mainnet() elif args.privnet: settings.setup_privnet() elif args.coznet: settings.setup_coznet() if args.theme: preferences.set_theme(args.theme) # Instantiate the blockchain and subscribe to notifications blockchain = LevelDBBlockchain(settings.LEVELDB_PATH) Blockchain.RegisterBlockchain(blockchain) # Try to set up a notification db if NotificationDB.instance(): NotificationDB.instance().start() # Start the prompt interface cli = PromptInterface() # Run things reactor.suggestThreadPoolSize(15) reactor.callInThread(cli.run) NodeLeader.Instance().Start() # reactor.run() is blocking, until `quit()` is called which stops the reactor. reactor.run() # After the reactor is stopped, gracefully shutdown the database. NotificationDB.close() Blockchain.Default().Dispose() NodeLeader.Instance().Shutdown()
def main(): parser = argparse.ArgumentParser() parser.add_argument("-m", "--mainnet", action="store_true", default=False, help="Use MainNet instead of the default TestNet") parser.add_argument("-p", "--privnet", action="store_true", default=False, help="Use PrivNet instead of the default TestNet") parser.add_argument("-c", "--config", action="store", help="Use a specific config file") parser.add_argument("-t", "--set-default-theme", dest="theme", choices=["dark", "light"], help="Set the default theme to be loaded from the config file. Default: 'dark'") parser.add_argument('--version', action='version', version='neo-python v{version}'.format(version=__version__)) parser.add_argument("-e", "--exec_command", action="store", help="Use a specific commands") args = parser.parse_args() if args.config and (args.mainnet or args.privnet): print("Cannot use both --config and --mainnet/--privnet arguments, please use only one.") exit(1) if args.mainnet and args.privnet: print("Cannot use both --mainnet and --privnet arguments") exit(1) # Setup depending on command line arguments. By default, the testnet settings are already loaded. if args.config: settings.setup(args.config) elif args.mainnet: settings.setup_mainnet() elif args.privnet: settings.setup_privnet() mycoms = [] mycoms2 = [] if args.exec_command: mycoms = args.exec_command.split(',') #print("exec:"+args.exec_command) for k in mycoms: mycoms2.append( codecs.decode(k, "hex").decode() ) if args.theme: preferences.set_theme(args.theme) # Instantiate the blockchain and subscribe to notifications blockchain = LevelDBBlockchain(settings.LEVELDB_PATH) Blockchain.RegisterBlockchain(blockchain) # Start the prompt interface cli = PromptInterface() cli.mycommands = mycoms2 #['oi', 'oi2'] # Run reactor.suggestThreadPoolSize(15) reactor.callInThread(cli.run) NodeLeader.Instance().Start() reactor.run()
def main(): parser = argparse.ArgumentParser() group = parser.add_mutually_exclusive_group() group.add_argument("-m", "--mainnet", action="store_true", default=False, help="Use MainNet instead of the default TestNet") group.add_argument("-p", "--privnet", action="store_true", default=False, help="Use PrivNet instead of the default TestNet") group.add_argument("--coznet", action="store_true", default=False, help="Use the CoZ network instead of the default TestNet") group.add_argument("-c", "--config", action="store", help="Use a specific config file") args = parser.parse_args() # Setup depending on command line arguments. By default, the testnet settings are already loaded. if args.config: settings.setup(args.config) elif args.mainnet: settings.setup_mainnet() elif args.privnet: settings.setup_privnet() elif args.coznet: settings.setup_coznet() # Setup the blockchain blockchain = LevelDBBlockchain(settings.LEVELDB_PATH) # logger.info(settings.LEVELDB_PATH) Blockchain.RegisterBlockchain(blockchain) dbloop = task.LoopingCall(Blockchain.Default().PersistBlocks) dbloop.start(.1) NodeLeader.Instance().Start() # Disable smart contract events for external smart contracts settings.set_log_smart_contract_events(True) logger.info("Using network: %s" % settings.net_name) # Start a thread with custom code d = threading.Thread(target=custom_background_code) d.setDaemon(True) # daemonizing the thread will kill it when the main thread is quit d.start() # Start SurTokenContract thread surTokenContract.start() # Hook up Klein API to Twisted reactor endpoint_description = "tcp:port=%s" % API_PORT endpoint = endpoints.serverFromString(reactor, endpoint_description) endpoint.listen(Site(app.resource())) # Run all the things (blocking call) logger.info("Everything setup and running. Waiting for events...") reactor.run() logger.info("Shutting down.")
def neo_loop(): blockchain = LevelDBBlockchain(settings.LEVELDB_PATH) Blockchain.RegisterBlockchain(blockchain) print("PersistBlocks task starting") dbloop = task.LoopingCall(Blockchain.Default().PersistBlocks) dbloop.start(.01) print("Node task starting") NodeLeader.Instance().Start() print("Entering main reactor loop") reactor.run(installSignalHandlers=False)
def __init__(self, path, passwordKey, create): if create: self._path = path self._iv = bytes( Random.get_random_bytes(16)) self._master_key = bytes(Random.get_random_bytes(32)) self._keys = [] if Blockchain.Default() is None: self._indexedDB= LevelDBBlockchain(Settings.LEVELDB_PATH) Blockchain.RegisterBlockchain(self._indexedDB) else: self._indexedDB = Blockchain.Default() #self._node = RemoteNode(url=TEST_NODE) self._current_height = Blockchain.Default().HeaderHeight + 1 if Blockchain.Default() is not None else 0 self.BuildDatabase() self.__log.debug("iv::: %s " % self._iv) self.__log.debug("mk::: A%s " % self._master_key) passwordHash = hashlib.sha256(passwordKey.encode('utf-8')).digest() master = AES.new(self._master_key, AES.MODE_CBC, self._iv) masterKey = master.encrypt(passwordHash) self.SaveStoredData('PasswordHash', passwordHash) self.SaveStoredData('IV', self._iv), self.SaveStoredData('MasterKey', masterKey) # self.SaveStoredData('Version') { Version.Major, Version.Minor, Version.Build, Version.Revision }.Select(p => BitConverter.GetBytes(p)).SelectMany(p => p).ToArray()); self.SaveStoredData('Height', self._current_height) else: passwordHash = self.LoadStoredData('PasswordHash') if passwordHash is not None and passwordHash != hashlib.sha256(passwordKey): raise Exception("Cryptographic exception") self._iv = self.LoadStoredData('IV') self._master_key = self.LoadStoredData('MasterKey') self._keys = self.LoadKeyPair() self._contracts = self.LoadContracts() self._watch_only = self.LoadWatchOnly() self._coins = self.LoadCoins() self._current_height = self.LoadStoredData('Height') del passwordKey self._current_height = Blockchain.Default().HeaderHeight + 1 if Blockchain.Default() is not None else 0 self._blockThread = Thread(target=self.ProcessBlocks, name='Wallet.ProcessBlocks')
def createSender(config, wallet, pwd): global sender settings.setup(config) blockchain = LevelDBBlockchain(settings.LEVELDB_PATH) Blockchain.RegisterBlockchain(blockchain) sender = NRCSender(wallet, pwd) def signalHandler(signal, frame): sender.quit() sys.exit(0) signal.signal(signal.SIGINT, signalHandler) sender.runBackground() return sender
def main(): # Use TestNet settings.setup_testnet() # Setup the blockchain blockchain = LevelDBBlockchain(settings.chain_leveldb_path) Blockchain.RegisterBlockchain(blockchain) loop = asyncio.get_event_loop() # Start a reoccurring task with custom code loop.create_task(custom_background_code()) p2p = NetworkService() loop.create_task(p2p.start()) # block from here on loop.run_forever()
def main(): # Use TestNet #settings.setup_testnet() settings.setup_privnet("testnet.nos.io") # Setup the blockchain blockchain = LevelDBBlockchain(settings.chain_leveldb_path) Blockchain.RegisterBlockchain(blockchain) dbloop = task.LoopingCall(Blockchain.Default().PersistBlocks) dbloop.start(.1) NodeLeader.Instance().Start() # Disable smart contract events for external smart contracts settings.set_log_smart_contract_events(False) # Start a thread with custom code d = threading.Thread(target=custom_background_code) d.setDaemon( True ) # daemonizing the thread will kill it when the main thread is quit d.start() print("0 --- 0 -> STARTING") #Open the wallet and be ready wallethandler() # Hook up Klein API to Twisted reactor. # endpoint_description = "tcp:port=%s:interface=localhost" % API_PORT endpoint_description = 'tcp:port=%s' % API_PORT # If you want to make this service externally available (not only at localhost), # then remove the `interface=localhost` part: # endpoint_description = "tcp:port=%s" % API_PORT endpoint = endpoints.serverFromString(reactor, endpoint_description) endpoint.listen(Site(app.resource())) # Run all the things (blocking call) logger.info('Everything setup and running. Waiting for events...') reactor.run() logger.info('Shutting down.')
def main(): # Setup the blockchain settings.setup('protocol.faucet.json') blockchain = LevelDBBlockchain(settings.LEVELDB_PATH) Blockchain.RegisterBlockchain(blockchain) dbloop = task.LoopingCall(Blockchain.Default().PersistBlocks) dbloop.start(.1) NodeLeader.Instance().Start() port = os.environ.get('FAUCET_PORT', 8080) host = os.environ.get('FAUCET_HOST', 'localhost') store = ItemStore() store.app.run(host, int(port)) logger.info("Shutting down.")
def main(): parser = argparse.ArgumentParser() parser.add_argument("-m", "--mainnet", action="store_true", default=False, help="Use MainNet instead of the default TestNet") parser.add_argument("-p", "--privnet", action="store_true", default=False, help="Use PrivNet instead of the default TestNet") parser.add_argument("-c", "--config", action="store", help="Use a specific config file") parser.add_argument('--version', action='version', version='neo-python v{version}'.format(version=__version__)) args = parser.parse_args() if args.config and (args.mainnet or args.privnet): print("Cannot use both --config and --mainnet/--privnet arguments, please use only one.") exit(1) if args.mainnet and args.privnet: print("Cannot use both --mainnet and --privnet arguments") exit(1) # Setup depending on command line arguments. By default, the testnet settings are already loaded. if args.config: settings.setup(args.config) elif args.mainnet: settings.setup_mainnet() elif args.privnet: settings.setup_privnet() # Instantiate the blockchain and subscribe to notifications blockchain = LevelDBBlockchain(settings.LEVELDB_PATH) Blockchain.RegisterBlockchain(blockchain) dbloop = task.LoopingCall(Blockchain.Default().PersistBlocks) dbloop.start(.1) ndb = NotificationDB.instance() ndb.start() notif_server = NotificationRestApi() # Run reactor.suggestThreadPoolSize(15) NodeLeader.Instance().Start() port = 8000 logger.info("Starting notification-api server on port %s" % (port)) notif_server.app.run('0.0.0.0', port)
def main(): # Setup the blockchain blockchain = LevelDBBlockchain(settings.LEVELDB_PATH) Blockchain.RegisterBlockchain(blockchain) dbloop = task.LoopingCall(Blockchain.Default().PersistBlocks) dbloop.start(.1) NodeLeader.Instance().Start() # Start a thread with custom code d = threading.Thread(target=custom_background_code) d.setDaemon( True ) # daemonizing the thread will kill it when the main thread is quit d.start() # Run all the things (blocking call) reactor.run() logger.info("Shutting down.")
async def setup_and_start(loop): # Use TestNet settings.setup_testnet() # Setup the blockchain blockchain = LevelDBBlockchain(settings.chain_leveldb_path) Blockchain.RegisterBlockchain(blockchain) p2p = NetworkService() loop.create_task(p2p.start()) bg_task = loop.create_task(custom_background_code()) # Disable smart contract events for external smart contracts settings.set_log_smart_contract_events(False) # Run all the things (blocking call) logger.info("Everything setup and running. Waiting for events...") return bg_task
def main(): # Setup the blockchain blockchain = LevelDBBlockchain(settings.LEVELDB_PATH) Blockchain.RegisterBlockchain(blockchain) dbloop = task.LoopingCall(Blockchain.Default().PersistBlocks) dbloop.start(.1) NodeLeader.Instance().Start() # Start smart contract thread smart_contract.start() # Start a thread with listener for remote commands d = threading.Thread(target=Listener) d.setDaemon(True) d.start() # Run all the things (blocking call) logger.info("Everything setup and running. Waiting for events...") reactor.run() logger.info("Shutting down.")
def run(self): # bl: changing to 8 as recommended in the 8-10 range by localhuman (previously had this at 150) settings.set_max_peers(8) # Setup the blockchain self.blockchain = LevelDBBlockchain(settings.chain_leveldb_path) Blockchain.RegisterBlockchain(self.blockchain) NodeLeader.Instance().Start() dbloop = task.LoopingCall(Blockchain.Default().PersistBlocks) dbloop.start(.1) Blockchain.Default().PersistBlocks() # Disable smart contract events for external smart contracts settings.set_log_smart_contract_events(False) # if the wallet was set up (by setting a path and loading the password), then open it! if self.wallet_path: self.wallet_open() # Start a thread with custom code d = threading.Thread(target=self.whitelist_addresses) d.setDaemon(True) # daemonizing the thread will kill it when the main thread is quit d.start() # invoke any pre-start action that needs to occur before we start the reactor. # optional for subclasses to implement. self.pre_start() # Run all the things (blocking call) self.logger.info("Everything setup and running. Waiting for events...") reactor.run() self.logger.info("Shutting down") if self.wallet_path: self.wallet_close() Blockchain.Default().Dispose() NodeLeader.Instance().Shutdown() self.logger.info("Shut down.")
def main(): # Setup the blockchain # settings.setup('./neo-python/protocol.coz.json') blockchain = LevelDBBlockchain(settings.LEVELDB_PATH) Blockchain.RegisterBlockchain(blockchain) dbloop = task.LoopingCall(Blockchain.Default().PersistBlocks) dbloop.start(.1) NodeLeader.Instance().Start() # Disable smart contract events for external smart contracts settings.set_log_smart_contract_events(False) # Start a thread with custom code d = threading.Thread(target=log_block) d.setDaemon( True ) # daemonizing the thread will kill it when the main thread is quit d.start() # Run all the things (blocking call) logger.info("Everything setup and running. Waiting for events...") reactor.run() logger.info("Shutting down.")