public static SCPHistoryEntryV0 Decode(XdrDataInputStream stream)
        {
            var decodedSCPHistoryEntryV0 = new SCPHistoryEntryV0();
            var quorumSetssize           = stream.ReadInt();

            decodedSCPHistoryEntryV0.QuorumSets = new SCPQuorumSet[quorumSetssize];
            for (var i = 0; i < quorumSetssize; i++)
            {
                decodedSCPHistoryEntryV0.QuorumSets[i] = SCPQuorumSet.Decode(stream);
            }
            decodedSCPHistoryEntryV0.LedgerMessages = LedgerSCPMessages.Decode(stream);
            return(decodedSCPHistoryEntryV0);
        }
Ejemplo n.º 2
0
        public static SCPHistoryEntryV0 Decode(IByteReader stream)
        {
            SCPHistoryEntryV0 decodedSCPHistoryEntryV0 = new SCPHistoryEntryV0();
            int quorumSetssize = XdrEncoding.DecodeInt32(stream);

            decodedSCPHistoryEntryV0.QuorumSets = new SCPQuorumSet[quorumSetssize];
            for (int i = 0; i < quorumSetssize; i++)
            {
                decodedSCPHistoryEntryV0.QuorumSets[i] = SCPQuorumSet.Decode(stream);
            }
            decodedSCPHistoryEntryV0.LedgerMessages = LedgerSCPMessages.Decode(stream);
            return(decodedSCPHistoryEntryV0);
        }
Ejemplo n.º 3
0
        public static SCPQuorumSet Decode(IByteReader stream)
        {
            SCPQuorumSet decodedSCPQuorumSet = new SCPQuorumSet();

            decodedSCPQuorumSet.Threshold = Uint32.Decode(stream);
            int validatorssize = XdrEncoding.DecodeInt32(stream);

            decodedSCPQuorumSet.Validators = new PublicKey[validatorssize];
            for (int i = 0; i < validatorssize; i++)
            {
                decodedSCPQuorumSet.Validators[i] = PublicKey.Decode(stream);
            }
            int innerSetssize = XdrEncoding.DecodeInt32(stream);

            decodedSCPQuorumSet.InnerSets = new SCPQuorumSet[innerSetssize];
            for (int i = 0; i < innerSetssize; i++)
            {
                decodedSCPQuorumSet.InnerSets[i] = SCPQuorumSet.Decode(stream);
            }
            return(decodedSCPQuorumSet);
        }
Ejemplo n.º 4
0
        public static SCPQuorumSet Decode(XdrDataInputStream stream)
        {
            SCPQuorumSet decodedSCPQuorumSet = new SCPQuorumSet();

            decodedSCPQuorumSet.Threshold = Uint32.Decode(stream);
            int validatorssize = stream.ReadInt();

            decodedSCPQuorumSet.Validators = new PublicKey[validatorssize];
            for (int i = 0; i < validatorssize; i++)
            {
                decodedSCPQuorumSet.Validators[i] = PublicKey.Decode(stream);
            }
            int innerSetssize = stream.ReadInt();

            decodedSCPQuorumSet.InnerSets = new SCPQuorumSet[innerSetssize];
            for (int i = 0; i < innerSetssize; i++)
            {
                decodedSCPQuorumSet.InnerSets[i] = SCPQuorumSet.Decode(stream);
            }
            return(decodedSCPQuorumSet);
        }
Ejemplo n.º 5
0
        public static StellarMessage Decode(XdrDataInputStream stream)
        {
            StellarMessage decodedStellarMessage = new StellarMessage();
            MessageType    discriminant          = MessageType.Decode(stream);

            decodedStellarMessage.Discriminant = discriminant;

            switch (decodedStellarMessage.Discriminant.InnerValue)
            {
            case MessageType.MessageTypeEnum.ERROR_MSG:
                decodedStellarMessage.Error = Error.Decode(stream);
                break;

            case MessageType.MessageTypeEnum.HELLO:
                decodedStellarMessage.Hello = Hello.Decode(stream);
                break;

            case MessageType.MessageTypeEnum.AUTH:
                decodedStellarMessage.Auth = Auth.Decode(stream);
                break;

            case MessageType.MessageTypeEnum.DONT_HAVE:
                decodedStellarMessage.DontHave = DontHave.Decode(stream);
                break;

            case MessageType.MessageTypeEnum.GET_PEERS:
                break;

            case MessageType.MessageTypeEnum.PEERS:
                int peerssize = stream.ReadInt();
                decodedStellarMessage.Peers = new PeerAddress[peerssize];

                for (int i = 0; i < peerssize; i++)
                {
                    decodedStellarMessage.Peers[i] = PeerAddress.Decode(stream);
                }

                break;

            case MessageType.MessageTypeEnum.GET_TX_SET:
                decodedStellarMessage.TxSetHash = Uint256.Decode(stream);
                break;

            case MessageType.MessageTypeEnum.TX_SET:
                decodedStellarMessage.TxSet = TransactionSet.Decode(stream);
                break;

            case MessageType.MessageTypeEnum.TRANSACTION:
                decodedStellarMessage.Transaction = TransactionEnvelope.Decode(stream);
                break;

            case MessageType.MessageTypeEnum.GET_SCP_QUORUMSET:
                decodedStellarMessage.QSetHash = Uint256.Decode(stream);
                break;

            case MessageType.MessageTypeEnum.SCP_QUORUMSET:
                decodedStellarMessage.QSet = SCPQuorumSet.Decode(stream);
                break;

            case MessageType.MessageTypeEnum.SCP_MESSAGE:
                decodedStellarMessage.Envelope = SCPEnvelope.Decode(stream);
                break;

            case MessageType.MessageTypeEnum.GET_SCP_STATE:
                decodedStellarMessage.GetSCPLedgerSeq = Uint32.Decode(stream);
                break;
            }

            return(decodedStellarMessage);
        }