Ejemplo n.º 1
0
        protected Task ValidateNonceRevelation(RawNonceRevelationContent revelation, RawBlock rawBlock)
        {
            if (revelation.Level % Protocol.BlocksPerCommitment != 0)
            {
                throw new ValidationException("invalid seed nonce revelation level");
            }

            if (revelation.Metadata.BalanceUpdates.Count != 1)
            {
                throw new ValidationException("invalid seed nonce revelation balance updates count");
            }

            if (!(revelation.Metadata.BalanceUpdates[0] is RewardsUpdate))
            {
                throw new ValidationException("invalid seed nonce revelation balance update type");
            }

            if (revelation.Metadata.BalanceUpdates[0].Change != Protocol.RevelationReward)
            {
                throw new ValidationException("invalid seed nonce revelation balance update amount");
            }

            if (!Cache.Accounts.DelegateExists(revelation.Metadata.BalanceUpdates[0].Target) ||
                revelation.Metadata.BalanceUpdates[0].Target != rawBlock.Metadata.Baker)
            {
                throw new ValidationException("invalid seed nonce revelation baker");
            }

            return(Task.CompletedTask);
        }
Ejemplo n.º 2
0
        public async Task Init(Block block, RawOperation op, RawNonceRevelationContent content)
        {
            var revealedBlock = await Cache.Blocks.GetAsync(content.Level);

            Revelation = new NonceRevelationOperation
            {
                Id            = Cache.AppState.NextOperationId(),
                Block         = block,
                Level         = block.Level,
                Timestamp     = block.Timestamp,
                OpHash        = op.Hash,
                Baker         = block.Baker,
                Sender        = Cache.Accounts.GetDelegate(revealedBlock.BakerId),
                RevealedBlock = revealedBlock,
                RevealedLevel = content.Level
            };
        }
Ejemplo n.º 3
0
        public static async Task <NonceRevelationsCommit> Apply(ProtocolHandler proto, Block block, RawOperation op, RawNonceRevelationContent content)
        {
            var commit = new NonceRevelationsCommit(proto);
            await commit.Init(block, op, content);

            await commit.Apply();

            return(commit);
        }