Search in sources :

Example 1 with UtxoAccountsService

use of io.nuls.utxo.accounts.service.UtxoAccountsService in project nuls by nuls-io.

the class UtxoAccountsModuleBootstrap method start.

@Override
public void start() {
    Log.info("start utxoAccountsModule");
    // 启动进行本地数据一致性判断与回滚
    try {
        UtxoAccountsService utxoAccountsService = NulsContext.getServiceBean(UtxoAccountsService.class);
        UtxoAccountsStorageService utxoAccountsStorageService = NulsContext.getServiceBean(UtxoAccountsStorageService.class);
        BlockService blockService = NulsContext.getServiceBean(BlockService.class);
        long hadSynBlockHeight = utxoAccountsStorageService.getHadSynBlockHeight();
        // 启动处理数据一致性
        if (!utxoAccountsService.validateIntegrityBootstrap(hadSynBlockHeight)) {
            Log.error("start utxoAccountsModule fail." + hadSynBlockHeight);
            return;
        }
    } catch (Exception e) {
        Log.error(e);
        Log.error("start utxoAccountsModule fail.");
        return;
    }
    ScheduledThreadPoolExecutor executor = TaskManager.createScheduledThreadPool(1, new NulsThreadFactory(UtxoAccountsConstant.MODULE_ID_UTXOACCOUNTS, "utxoAccountsThread"));
    executor.scheduleAtFixedRate(NulsContext.getServiceBean(UtxoAccountsThread.class), 15, 1, TimeUnit.SECONDS);
}
Also used : UtxoAccountsThread(io.nuls.utxo.accounts.task.UtxoAccountsThread) NulsThreadFactory(io.nuls.kernel.thread.manager.NulsThreadFactory) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) UtxoAccountsStorageService(io.nuls.utxo.accounts.storage.service.UtxoAccountsStorageService) BlockService(io.nuls.protocol.service.BlockService) UtxoAccountsService(io.nuls.utxo.accounts.service.UtxoAccountsService)

Aggregations

NulsThreadFactory (io.nuls.kernel.thread.manager.NulsThreadFactory)1 BlockService (io.nuls.protocol.service.BlockService)1 UtxoAccountsService (io.nuls.utxo.accounts.service.UtxoAccountsService)1 UtxoAccountsStorageService (io.nuls.utxo.accounts.storage.service.UtxoAccountsStorageService)1 UtxoAccountsThread (io.nuls.utxo.accounts.task.UtxoAccountsThread)1 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)1