Beispiel #1
0
 public async Task UpdateBlockchainStatus(BlockchainStatus blockchainStatus)
 {
     using (var context = new NxtContext())
     {
         context.BlockchainStatus.Attach(blockchainStatus);
         context.Entry(blockchainStatus).State = EntityState.Modified;
         await context.SaveChangesAsync();
     }
 }
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);
        }