Esempio n. 1
0
 internal ConsensusPayload[] GetCommitPayloadsFromRecoveryMessage(ConsensusContext context, ConsensusPayload payload)
 {
     return(CommitMessages.Values.Select(p => new ConsensusPayload
     {
         Version = payload.Version,
         PrevHash = payload.PrevHash,
         BlockIndex = payload.BlockIndex,
         ValidatorIndex = p.ValidatorIndex,
         ConsensusMessage = new Commit
         {
             ViewNumber = p.ViewNumber,
             Signature = p.Signature
         },
         Witness = new Witness
         {
             InvocationScript = p.InvocationScript,
             VerificationScript = Contract.CreateSignatureRedeemScript(context.Validators[p.ValidatorIndex])
         }
     }).ToArray());
 }
Esempio n. 2
0
 internal ConsensusPayload[] GetChangeViewPayloads(ConsensusContext context, ConsensusPayload payload)
 {
     return(ChangeViewMessages.Values.Select(p => new ConsensusPayload
     {
         Version = payload.Version,
         PrevHash = payload.PrevHash,
         BlockIndex = payload.BlockIndex,
         ValidatorIndex = p.ValidatorIndex,
         ConsensusMessage = new ChangeView
         {
             ViewNumber = p.OriginalViewNumber,
             Timestamp = p.Timestamp
         },
         Witness = new Witness
         {
             InvocationScript = p.InvocationScript,
             VerificationScript = Contract.CreateSignatureRedeemScript(context.Validators[p.ValidatorIndex])
         }
     }).ToArray());
 }
Esempio n. 3
0
 internal ConsensusPayload GetPrepareRequestPayload(ConsensusContext context, ConsensusPayload payload)
 {
     if (PrepareRequestMessage == null)
     {
         return(null);
     }
     if (!PreparationMessages.TryGetValue((int)context.Block.ConsensusData.PrimaryIndex, out RecoveryMessage.PreparationPayloadCompact compact))
     {
         return(null);
     }
     return(new ConsensusPayload
     {
         Version = payload.Version,
         PrevHash = payload.PrevHash,
         BlockIndex = payload.BlockIndex,
         ValidatorIndex = (ushort)context.Block.ConsensusData.PrimaryIndex,
         ConsensusMessage = PrepareRequestMessage,
         Witness = new Witness
         {
             InvocationScript = compact.InvocationScript,
             VerificationScript = Contract.CreateSignatureRedeemScript(context.Validators[context.Block.ConsensusData.PrimaryIndex])
         }
     });
 }