Ejemplo n.º 1
0
        public async Task Init(Block block, RawOperation op, RawRevealContent content)
        {
            var id = Cache.AppState.NextOperationId();

            var sender = await Cache.Accounts.GetAsync(content.Source);

            sender.Delegate ??= Cache.Accounts.GetDelegate(sender.DelegateId);

            PubKey = content.PublicKey;
            Reveal = new RevealOperation
            {
                Id           = id,
                OpHash       = op.Hash,
                Block        = block,
                Level        = block.Level,
                Timestamp    = block.Timestamp,
                BakerFee     = content.Fee,
                Counter      = content.Counter,
                GasLimit     = content.GasLimit,
                StorageLimit = content.StorageLimit,
                Sender       = sender,
                Status       = content.Metadata.Result.Status switch
                {
                    "applied" => OperationStatus.Applied,
                    "backtracked" => OperationStatus.Backtracked,
                    "failed" => OperationStatus.Failed,
                    "skipped" => OperationStatus.Skipped,
                    _ => throw new Exception($"Invalid status '{content.Metadata.Result.Status}'")
                },
Ejemplo n.º 2
0
        protected async Task ValidateReveal(RawRevealContent reveal, RawBlock rawBlock)
        {
            if (!await Cache.Accounts.ExistsAsync(reveal.Source))
            {
                throw new ValidationException("unknown source account");
            }

            ValidateFeeBalanceUpdates(
                reveal.Metadata.BalanceUpdates,
                rawBlock.Metadata.Baker,
                reveal.Source,
                reveal.Fee,
                rawBlock.Metadata.LevelInfo.Cycle);
        }