Beispiel #1
0
        private NxtWalletDb InitWallet(string walletfile)
        {
            var wallet = new NxtWalletDb(walletfile);

            if (wallet.IsInitialized())
            {
                return(wallet);
            }

            var blockchainStatus = serverInfoService.GetBlockchainStatus().Result;

            wallet.Init(blockchainStatus.LastBlockId);
            return(wallet);
        }
Beispiel #2
0
        public async Task <BlockchainStatus> GetBlockchainStatus()
        {
            var status = new BlockchainStatus();

            var blockchainStatusReply = await _serverInfoService.GetBlockchainStatus();

            var lastBlock = await _blockService.GetBlock(BlockLocator.ByBlockId(blockchainStatusReply.LastBlockId));

            var confirmedBlock = await _blockService.GetBlock(BlockLocator.ByHeight(blockchainStatusReply.NumberOfBlocks - 11));

            var secureBlock = await _blockService.GetBlock(BlockLocator.ByHeight(blockchainStatusReply.NumberOfBlocks - 721));

            status.LastKnownBlockId        = blockchainStatusReply.LastBlockId.ToSigned();
            status.LastKnownBlockTimestamp = lastBlock.Timestamp;

            status.LastConfirmedBlockId        = confirmedBlock.BlockId.ToSigned();
            status.LastConfirmedBlockTimestamp = confirmedBlock.Timestamp;

            status.LastSecureBlockId        = secureBlock.BlockId.ToSigned();
            status.LastSecureBlockTimestamp = secureBlock.Timestamp;

            return(status);
        }
Beispiel #3
0
 public GetBlockchainStatusTest(IServerInfoService serverInfoService, ILogger logger)
 {
     _logger = logger;
     _getBlockchainStatusReply = serverInfoService.GetBlockchainStatus().Result;
 }