Пример #1
0
        public BytesValue GetTriggerInformationForBlockHeaderExtraData(BytesValue consensusCommandBytes)
        {
            if (consensusCommandBytes == null)
            {
                return(new AElfConsensusTriggerInformation
                {
                    Pubkey = Pubkey,
                    Behaviour = AElfConsensusBehaviour.UpdateValue
                }.ToBytesValue());
            }

            var command = consensusCommandBytes.ToConsensusCommand();
            var hint    = command.Hint.ToAElfConsensusHint();

            if (hint.Behaviour == AElfConsensusBehaviour.UpdateValue)
            {
                var newInValue      = _inValueCache.GetInValue(hint.RoundId);
                var previousInValue = _inValueCache.GetInValue(hint.PreviousRoundId);
                Logger.LogTrace($"New in value {newInValue} for round of id {hint.RoundId}");
                Logger.LogTrace($"Previous in value {previousInValue} for round of id {hint.PreviousRoundId}");
                var trigger = new AElfConsensusTriggerInformation
                {
                    Pubkey          = Pubkey,
                    InValue         = newInValue,
                    PreviousInValue = previousInValue,
                    Behaviour       = hint.Behaviour
                };

                return(trigger.ToBytesValue());
            }

            return(new AElfConsensusTriggerInformation
            {
                Pubkey = Pubkey,
                Behaviour = hint.Behaviour
            }.ToBytesValue());
        }