Esempio 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,
                    _ => throw new NotImplementedException()
                }
            };
        }
Esempio 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);
        }
Esempio n. 3
0
        public static async Task <RevealsCommit> Apply(ProtocolHandler proto, Block block, RawOperation op, RawRevealContent content)
        {
            var commit = new RevealsCommit(proto);
            await commit.Init(block, op, content);

            await commit.Apply();

            return(commit);
        }