Ejemplo n.º 1
0
 internal ExtensiblePayload[] GetCommitPayloadsFromRecoveryMessage(ConsensusContext context)
 {
     return(CommitMessages.Values.Select(p => context.CreatePayload(new Commit
     {
         BlockIndex = BlockIndex,
         ValidatorIndex = p.ValidatorIndex,
         ViewNumber = p.ViewNumber,
         Signature = p.Signature
     }, p.InvocationScript)).ToArray());
 }
Ejemplo n.º 2
0
 internal ExtensiblePayload[] GetChangeViewPayloads(ConsensusContext context)
 {
     return(ChangeViewMessages.Values.Select(p => context.CreatePayload(new ChangeView
     {
         BlockIndex = BlockIndex,
         ValidatorIndex = p.ValidatorIndex,
         ViewNumber = p.OriginalViewNumber,
         Timestamp = p.Timestamp
     }, p.InvocationScript)).ToArray());
 }
Ejemplo n.º 3
0
 internal ExtensiblePayload GetPrepareRequestPayload(ConsensusContext context)
 {
     if (PrepareRequestMessage == null)
     {
         return(null);
     }
     if (!PreparationMessages.TryGetValue(context.Block.PrimaryIndex, out PreparationPayloadCompact compact))
     {
         return(null);
     }
     return(context.CreatePayload(PrepareRequestMessage, compact.InvocationScript));
 }
Ejemplo n.º 4
0
        internal ExtensiblePayload[] GetPrepareResponsePayloads(ConsensusContext context)
        {
            UInt256 preparationHash = PreparationHash ?? context.PreparationPayloads[context.Block.PrimaryIndex]?.Hash;

            if (preparationHash is null)
            {
                return(Array.Empty <ExtensiblePayload>());
            }
            return(PreparationMessages.Values.Where(p => p.ValidatorIndex != context.Block.PrimaryIndex).Select(p => context.CreatePayload(new PrepareResponse
            {
                BlockIndex = BlockIndex,
                ValidatorIndex = p.ValidatorIndex,
                ViewNumber = ViewNumber,
                PreparationHash = preparationHash
            }, p.InvocationScript)).ToArray());
        }