public async Task Mine_Test() { var chain = await _blockchainService.GetChainAsync(); var blockStateSet = new BlockStateSet { BlockHash = chain.BestChainHash, BlockHeight = chain.BestChainHeight, }; await _blockStateSetManger.SetBlockStateSetAsync(blockStateSet); var transactions = _kernelTestHelper.GenerateTransactions(5, chain.BestChainHeight, chain.BestChainHash); await _transactionPoolService.UpdateTransactionPoolByBestChainAsync(chain.BestChainHash, chain.BestChainHeight); await _transactionPoolService.AddTransactionsAsync(transactions); await Task.Delay(200); await _transactionPoolService.UpdateTransactionPoolByBestChainAsync(chain.BestChainHash, chain.BestChainHeight); { await _transactionPackingOptionProvider.SetTransactionPackingOptionAsync(new BlockIndex { BlockHash = chain.BestChainHash, BlockHeight = chain.BestChainHeight }, false); var blockTime = TimestampHelper.GetUtcNow(); var result = await _minerService.MineAsync(chain.BestChainHash, chain.BestChainHeight, blockTime, TimestampHelper.DurationFromSeconds(4)); await CheckMiningResultAsync(result, blockTime, 0); } { await _transactionPackingOptionProvider.SetTransactionPackingOptionAsync(new BlockIndex { BlockHash = chain.BestChainHash, BlockHeight = chain.BestChainHeight }, true); await _blockTransactionLimitProvider.SetLimitAsync(new BlockIndex { BlockHash = chain.BestChainHash, BlockHeight = chain.BestChainHeight }, 3); var blockTime = TimestampHelper.GetUtcNow(); var result = await _minerService.MineAsync(chain.BestChainHash, chain.BestChainHeight, blockTime, TimestampHelper.DurationFromSeconds(4)); await CheckMiningResultAsync(result, blockTime, 2); } }
public async Task IterationSetup() { var transactions = await _osTestHelper.GenerateTransferTransactions(TransactionCount); await _transactionPoolService.AddTransactionsAsync(transactions); var chain = await _blockchainService.GetChainAsync(); _block = _osTestHelper.GenerateBlock(chain.BestChainHash, chain.BestChainHeight, transactions); await _blockchainService.AddBlockAsync(_block); await _chainBlockLinks.SetAsync( chain.Id.ToStorageKey() + KernelConstants.StorageKeySeparator + _block.GetHash().ToStorageKey(), new ChainBlockLink() { BlockHash = _block.GetHash(), Height = _block.Height, PreviousBlockHash = _block.Header.PreviousBlockHash, IsLinked = true }); await _blockchainService.SetBestChainAsync(chain, _block.Height, _block.GetHash()); }
public async Task HandleTransactionsReceivedTest() { await _transactionPoolService.AddTransactionsAsync(_transactions); }
public async Task HandleEventAsync(TransactionsReceivedEvent eventData) { await _transactionPoolService.AddTransactionsAsync(eventData.Transactions); }
public async Task BroadcastTransactions(IEnumerable <Transaction> transactions) { await _transactionPoolService.AddTransactionsAsync(transactions); }