private void ProcessTinyBlock(TinyBlockInput tinyBlockInput)
        {
            TryToGetCurrentRoundInformation(out var currentRound);

            currentRound.RealTimeMinersInformation[_processingBlockMinerPubkey].ActualMiningTimes
                .Add(tinyBlockInput.ActualMiningTime);
            currentRound.RealTimeMinersInformation[_processingBlockMinerPubkey].ProducedBlocks =
                tinyBlockInput.ProducedBlocks;
            var producedTinyBlocks =
                currentRound.RealTimeMinersInformation[_processingBlockMinerPubkey].ProducedTinyBlocks;
            currentRound.RealTimeMinersInformation[_processingBlockMinerPubkey].ProducedTinyBlocks =
                producedTinyBlocks.Add(1);

            Assert(TryToUpdateRoundInformation(currentRound), "Failed to update round information.");
        }
Пример #2
0
        private void ProcessTinyBlock(TinyBlockInput tinyBlockInput)
        {
            TryToGetCurrentRoundInformation(out var currentRound);

            Context.LogDebug(() =>
                             $"Processing tiny block:\n {currentRound}\n" +
                             $"Current height: {Context.CurrentHeight}\nPrevious block hash: {Context.PreviousBlockHash.ToHex()}");

            currentRound.RealTimeMinersInformation[_processingBlockMinerPubkey].ActualMiningTimes
            .Add(tinyBlockInput.ActualMiningTime);
            currentRound.RealTimeMinersInformation[_processingBlockMinerPubkey].ProducedBlocks =
                tinyBlockInput.ProducedBlocks;
            var producedTinyBlocks =
                currentRound.RealTimeMinersInformation[_processingBlockMinerPubkey].ProducedTinyBlocks;

            currentRound.RealTimeMinersInformation[_processingBlockMinerPubkey].ProducedTinyBlocks =
                producedTinyBlocks.Add(1);

            Assert(TryToUpdateRoundInformation(currentRound), "Failed to update round information.");
        }
Пример #3
0
        public async Task Update_TinyBlockInformation_Test()
        {
            await AEDPoSContract_FirstRound_BootMiner_Test();

            var roundInfo = await AEDPoSContractStub.GetCurrentRoundInformation.CallAsync(new Empty());

            BlockTimeProvider.SetBlockTime(BlockchainStartTimestamp + new Duration
            {
                Seconds = AEDPoSContractTestConstants.MiningInterval.Div(1000)
            });
            var input = new TinyBlockInput
            {
                RoundId          = roundInfo.RoundId,
                ProducedBlocks   = 4,
                ActualMiningTime = BlockTimeProvider.GetBlockTime()
            };
            var transactionResult = await AEDPoSContractStub.UpdateTinyBlockInformation.SendAsync(input);

            transactionResult.TransactionResult.Status.ShouldBe(TransactionResultStatus.Mined);
        }
Пример #4
0
        public override Empty UpdateTinyBlockInformation(TinyBlockInput input)
        {
            Assert(TryToGetCurrentRoundInformation(out var round), "Round information not found.");
            Assert(input.RoundId == round.RoundId, "Round Id not matched.");

            var publicKey = Context.RecoverPublicKey().ToHex();

            if (!round.RealTimeMinersInformation.Keys.Contains(publicKey))
            {
                return(new Empty());
            }

            round.RealTimeMinersInformation[publicKey].ActualMiningTimes.Add(input.ActualMiningTime);
            round.RealTimeMinersInformation[publicKey].ProducedBlocks = input.ProducedBlocks;
            var producedTinyBlocks = round.RealTimeMinersInformation[publicKey].ProducedTinyBlocks;

            round.RealTimeMinersInformation[publicKey].ProducedTinyBlocks = producedTinyBlocks.Add(1);

            Assert(TryToUpdateRoundInformation(round), "Failed to update round information.");

            return(new Empty());
        }
Пример #5
0
 public override Empty UpdateTinyBlockInformation(TinyBlockInput input)
 {
     ProcessConsensusInformation(input);
     return(new Empty());
 }