Exemple #1
0
        public async Task <Sp8deBlock> Produce(IKeySecret producerKey)
        {
            var block = await blockStorage.GetLatestBlock() ?? new Sp8deBlock();

            var transactions = await transactionStorage.GetPending(new Random().Next(1, 200));

            if (transactions.Count == 0 && DateConverter.UtcNow - block.Timestamp < (60 * 15)) //skip empty blocks
            {
                return(null);
            }

            block = GenerateNewBlock(transactions, block, producerKey);

            await blockStorage.Add(block);

            foreach (var item in transactions)
            {
                item.Status = Sp8deTransactionStatus.Confirmed;
                item.Meta   = new TransactionMeta()
                {
                    BlockId = block.Id
                };
            }

            await transactionStorage.Update(transactions);

            return(block);
        }
Exemple #2
0
 public async Task <ActionResult <Sp8deBlock> > GetLatestBlock()
 {
     return(await blockStorage.GetLatestBlock());
 }