public override async Task Commit(IBlock block) { var rawBlock = block as RawBlock; var blockCommit = await BlockCommit.Apply(this, rawBlock); var bootstrapCommit = await BootstrapCommit.Apply(this, blockCommit.Block, rawBlock); await VotingCommit.Apply(this, rawBlock); var brCommit = await BakingRightsCommit.Apply(this, blockCommit.Block, bootstrapCommit.BootstrapedAccounts); await CycleCommit.Apply(this, blockCommit.Block, bootstrapCommit.BootstrapedAccounts); await DelegatorCycleCommit.Apply(this, blockCommit.Block, bootstrapCommit.BootstrapedAccounts); await BakerCycleCommit.Apply(this, blockCommit.Block, bootstrapCommit.BootstrapedAccounts, brCommit.FutureBakingRights, brCommit.FutureEndorsingRights); await StateCommit.Apply(this, blockCommit.Block, rawBlock); }
public override async Task Commit(IBlock block) { var rawBlock = block as RawBlock; var blockCommit = await BlockCommit.Apply(this, rawBlock); await VotingCommit.Apply(this, blockCommit.Block, rawBlock); await FreezerCommit.Apply(this, blockCommit.Block, rawBlock); await RevelationPenaltyCommit.Apply(this, blockCommit.Block, rawBlock); await DeactivationCommit.Apply(this, blockCommit.Block, rawBlock); #region operations 0 foreach (var operation in rawBlock.Operations[0]) { foreach (var content in operation.Contents) { switch (content) { case RawEndorsementContent endorsement: await EndorsementsCommit.Apply(this, blockCommit.Block, operation, endorsement); break; default: throw new Exception($"'{content.GetType()}' is not expected in operations[0]"); } } } #endregion #region operations 1 foreach (var operation in rawBlock.Operations[1]) { foreach (var content in operation.Contents) { if (content is RawProposalContent proposal) { await ProposalsCommit.Apply(this, blockCommit.Block, operation, proposal); } else if (content is RawBallotContent ballot) { await BallotsCommit.Apply(this, blockCommit.Block, operation, ballot); } else { throw new Exception($"'{content.GetType()}' is not expected in operations[1]"); } } } #endregion #region operations 2 foreach (var operation in rawBlock.Operations[2]) { foreach (var content in operation.Contents) { switch (content) { case RawActivationContent activation: await ActivationsCommit.Apply(this, blockCommit.Block, operation, activation); break; case RawDoubleBakingEvidenceContent doubleBaking: await DoubleBakingCommit.Apply(this, blockCommit.Block, operation, doubleBaking); break; case RawDoubleEndorsingEvidenceContent doubleEndorsing: await DoubleEndorsingCommit.Apply(this, blockCommit.Block, operation, doubleEndorsing); break; case RawNonceRevelationContent revelation: await NonceRevelationsCommit.Apply(this, blockCommit.Block, operation, revelation); break; default: throw new Exception($"'{content.GetType()}' is not expected in operations[2]"); } } } #endregion #region operations 3 foreach (var operation in rawBlock.Operations[3]) { Cache.AppState.IncreaseManagerCounter(operation.Contents.Count); foreach (var content in operation.Contents) { switch (content) { case RawRevealContent reveal: await RevealsCommit.Apply(this, blockCommit.Block, operation, reveal); break; case RawDelegationContent delegation: await DelegationsCommit.Apply(this, blockCommit.Block, operation, delegation); break; case RawOriginationContent origination: await OriginationsCommit.Apply(this, blockCommit.Block, operation, origination); break; case RawTransactionContent transaction: var parent = await TransactionsCommit.Apply(this, blockCommit.Block, operation, transaction); if (transaction.Metadata.InternalResults != null) { foreach (var internalContent in transaction.Metadata.InternalResults) { switch (internalContent) { case RawInternalTransactionResult internalTransaction: await TransactionsCommit.Apply(this, blockCommit.Block, parent.Transaction, internalTransaction); break; case RawInternalDelegationResult internalDelegation: await DelegationsCommit.Apply(this, blockCommit.Block, parent.Transaction, internalDelegation); break; case RawInternalOriginationResult internalOrigination: await OriginationsCommit.Apply(this, blockCommit.Block, parent.Transaction, internalOrigination); break; default: throw new Exception($"internal '{internalContent.GetType()}' is not expected"); } } } break; default: throw new Exception($"'{content.GetType()}' is not expected in operations[3]"); } } } #endregion var brCommit = await BakingRightsCommit.Apply(this, blockCommit.Block); var cycleCommit = await CycleCommit.Apply(this, blockCommit.Block); await DelegatorCycleCommit.Apply(this, blockCommit.Block, cycleCommit.FutureCycle); await BakerCycleCommit.Apply(this, blockCommit.Block, cycleCommit.FutureCycle, brCommit.FutureBakingRights, brCommit.FutureEndorsingRights, cycleCommit.Snapshots, brCommit.CurrentRights); await StateCommit.Apply(this, blockCommit.Block, rawBlock); }