示例#1
0
        public static SCPNomination Decode(XdrDataInputStream stream)
        {
            SCPNomination decodedSCPNomination = new SCPNomination();

            decodedSCPNomination.QuorumSetHash = Hash.Decode(stream);
            int votessize = stream.ReadInt();

            decodedSCPNomination.Votes = new Value[votessize];

            for (int i = 0; i < votessize; i++)
            {
                decodedSCPNomination.Votes[i] = Value.Decode(stream);
            }

            int acceptedsize = stream.ReadInt();

            decodedSCPNomination.Accepted = new Value[acceptedsize];

            for (int i = 0; i < acceptedsize; i++)
            {
                decodedSCPNomination.Accepted[i] = Value.Decode(stream);
            }

            return(decodedSCPNomination);
        }
示例#2
0
            public static SCPStatementPledges Decode(XdrDataInputStream stream)
            {
                var decodedSCPStatementPledges = new SCPStatementPledges();
                var discriminant = SCPStatementType.Decode(stream);

                decodedSCPStatementPledges.Discriminant = discriminant;
                switch (decodedSCPStatementPledges.Discriminant.InnerValue)
                {
                case SCPStatementType.SCPStatementTypeEnum.SCP_ST_PREPARE:
                    decodedSCPStatementPledges.Prepare = SCPStatementPrepare.Decode(stream);
                    break;

                case SCPStatementType.SCPStatementTypeEnum.SCP_ST_CONFIRM:
                    decodedSCPStatementPledges.Confirm = SCPStatementConfirm.Decode(stream);
                    break;

                case SCPStatementType.SCPStatementTypeEnum.SCP_ST_EXTERNALIZE:
                    decodedSCPStatementPledges.Externalize = SCPStatementExternalize.Decode(stream);
                    break;

                case SCPStatementType.SCPStatementTypeEnum.SCP_ST_NOMINATE:
                    decodedSCPStatementPledges.Nominate = SCPNomination.Decode(stream);
                    break;
                }
                return(decodedSCPStatementPledges);
            }
 public static void Encode(IByteWriter stream, SCPNomination encodedSCPNomination) {
   Hash.Encode(stream, encodedSCPNomination.QuorumSetHash);
   int votessize = encodedSCPNomination.Votes.Length;
   XdrEncoding.EncodeInt32(votessize, stream);
   for (int i = 0; i < votessize; i++) {
     Value.Encode(stream, encodedSCPNomination.Votes[i]);
   }
   int acceptedsize = encodedSCPNomination.Accepted.Length;
   XdrEncoding.EncodeInt32(acceptedsize, stream);
   for (int i = 0; i < acceptedsize; i++) {
     Value.Encode(stream, encodedSCPNomination.Accepted[i]);
   }
 }
 public static SCPNomination Decode(IByteReader stream) {
   SCPNomination decodedSCPNomination = new SCPNomination();
   decodedSCPNomination.QuorumSetHash = Hash.Decode(stream);
   int votessize = XdrEncoding.DecodeInt32(stream);
   decodedSCPNomination.Votes = new Value[votessize];
   for (int i = 0; i < votessize; i++) {
     decodedSCPNomination.Votes[i] = Value.Decode(stream);
   }
   int acceptedsize = XdrEncoding.DecodeInt32(stream);
   decodedSCPNomination.Accepted = new Value[acceptedsize];
   for (int i = 0; i < acceptedsize; i++) {
     decodedSCPNomination.Accepted[i] = Value.Decode(stream);
   }
   return decodedSCPNomination;
 }
示例#5
0
        public static void Encode(IByteWriter stream, SCPNomination encodedSCPNomination)
        {
            Hash.Encode(stream, encodedSCPNomination.QuorumSetHash);
            int votessize = encodedSCPNomination.Votes.Length;

            XdrEncoding.EncodeInt32(votessize, stream);
            for (int i = 0; i < votessize; i++)
            {
                Value.Encode(stream, encodedSCPNomination.Votes[i]);
            }
            int acceptedsize = encodedSCPNomination.Accepted.Length;

            XdrEncoding.EncodeInt32(acceptedsize, stream);
            for (int i = 0; i < acceptedsize; i++)
            {
                Value.Encode(stream, encodedSCPNomination.Accepted[i]);
            }
        }
        public static void Encode(XdrDataOutputStream stream, SCPNomination encodedSCPNomination)
        {
            Hash.Encode(stream, encodedSCPNomination.QuorumSetHash);
            var votessize = encodedSCPNomination.Votes.Length;

            stream.WriteInt(votessize);
            for (var i = 0; i < votessize; i++)
            {
                Value.Encode(stream, encodedSCPNomination.Votes[i]);
            }
            var acceptedsize = encodedSCPNomination.Accepted.Length;

            stream.WriteInt(acceptedsize);
            for (var i = 0; i < acceptedsize; i++)
            {
                Value.Encode(stream, encodedSCPNomination.Accepted[i]);
            }
        }
示例#7
0
        public static SCPNomination Decode(IByteReader stream)
        {
            SCPNomination decodedSCPNomination = new SCPNomination();

            decodedSCPNomination.QuorumSetHash = Hash.Decode(stream);
            int votessize = XdrEncoding.DecodeInt32(stream);

            decodedSCPNomination.Votes = new Value[votessize];
            for (int i = 0; i < votessize; i++)
            {
                decodedSCPNomination.Votes[i] = Value.Decode(stream);
            }
            int acceptedsize = XdrEncoding.DecodeInt32(stream);

            decodedSCPNomination.Accepted = new Value[acceptedsize];
            for (int i = 0; i < acceptedsize; i++)
            {
                decodedSCPNomination.Accepted[i] = Value.Decode(stream);
            }
            return(decodedSCPNomination);
        }
示例#8
0
            public static void Encode(XdrDataOutputStream stream, SCPStatementPledges encodedSCPStatementPledges)
            {
                stream.WriteInt((int)encodedSCPStatementPledges.Discriminant.InnerValue);
                switch (encodedSCPStatementPledges.Discriminant.InnerValue)
                {
                case SCPStatementType.SCPStatementTypeEnum.SCP_ST_PREPARE:
                    SCPStatementPrepare.Encode(stream, encodedSCPStatementPledges.Prepare);
                    break;

                case SCPStatementType.SCPStatementTypeEnum.SCP_ST_CONFIRM:
                    SCPStatementConfirm.Encode(stream, encodedSCPStatementPledges.Confirm);
                    break;

                case SCPStatementType.SCPStatementTypeEnum.SCP_ST_EXTERNALIZE:
                    SCPStatementExternalize.Encode(stream, encodedSCPStatementPledges.Externalize);
                    break;

                case SCPStatementType.SCPStatementTypeEnum.SCP_ST_NOMINATE:
                    SCPNomination.Encode(stream, encodedSCPStatementPledges.Nominate);
                    break;
                }
            }