Ejemplo n.º 1
0
        public static LedgerUpgrade Decode(XdrDataInputStream stream)
        {
            LedgerUpgrade     decodedLedgerUpgrade = new LedgerUpgrade();
            LedgerUpgradeType discriminant         = LedgerUpgradeType.Decode(stream);

            decodedLedgerUpgrade.Discriminant = discriminant;

            switch (decodedLedgerUpgrade.Discriminant.InnerValue)
            {
            case LedgerUpgradeType.LedgerUpgradeTypeEnum.LEDGER_UPGRADE_VERSION:
                decodedLedgerUpgrade.NewLedgerVersion = Uint32.Decode(stream);
                break;

            case LedgerUpgradeType.LedgerUpgradeTypeEnum.LEDGER_UPGRADE_BASE_FEE:
                decodedLedgerUpgrade.NewBaseFee = Uint32.Decode(stream);
                break;

            case LedgerUpgradeType.LedgerUpgradeTypeEnum.LEDGER_UPGRADE_MAX_TX_SET_SIZE:
                decodedLedgerUpgrade.NewMaxTxSetSize = Uint32.Decode(stream);
                break;

            case LedgerUpgradeType.LedgerUpgradeTypeEnum.LEDGER_UPGRADE_BASE_RESERVE:
                decodedLedgerUpgrade.NewBaseReserve = Uint32.Decode(stream);
                break;
            }

            return(decodedLedgerUpgrade);
        }
Ejemplo n.º 2
0
 public static void Encode(XdrDataOutputStream stream, TopologyResponseBody encodedTopologyResponseBody)
 {
     PeerStatList.Encode(stream, encodedTopologyResponseBody.InboundPeers);
     PeerStatList.Encode(stream, encodedTopologyResponseBody.OutboundPeers);
     Uint32.Encode(stream, encodedTopologyResponseBody.TotalInboundPeerCount);
     Uint32.Encode(stream, encodedTopologyResponseBody.TotalOutboundPeerCount);
 }
Ejemplo n.º 3
0
        /// <summary>
        ///     Generates Transaction XDR object.
        /// </summary>
        /// <returns></returns>
        public xdr.Transaction ToXdr()
        {
            // fee
            var fee = new Uint32 { InnerValue = Fee };

            // sequenceNumber
            var sequenceNumberUint = new Uint64 { InnerValue = SequenceNumber };
            var sequenceNumber = new SequenceNumber { InnerValue = sequenceNumberUint };

            // sourceAccount
            var sourceAccount = new AccountID { InnerValue = SourceAccount.XdrPublicKey };

            // operations
            var operations = new xdr.Operation[Operations.Length];

            for (var i = 0; i < Operations.Length; i++)
                operations[i] = Operations[i].ToXdr();

            // ext
            var ext = new xdr.Transaction.TransactionExt { Discriminant = 0 };

            var transaction = new xdr.Transaction
            {
                Fee = fee,
                SeqNum = sequenceNumber,
                SourceAccount = sourceAccount,
                Operations = operations,
                Memo = Memo.ToXdr(),
                TimeBounds = TimeBounds?.ToXdr(),
                Ext = ext
            };
            return transaction;
        }
 public static void Encode(XdrDataOutputStream stream,
                           TransactionHistoryResultEntry encodedTransactionHistoryResultEntry)
 {
     Uint32.Encode(stream, encodedTransactionHistoryResultEntry.LedgerSeq);
     TransactionResultSet.Encode(stream, encodedTransactionHistoryResultEntry.TxResultSet);
     TransactionHistoryResultEntryExt.Encode(stream, encodedTransactionHistoryResultEntry.Ext);
 }
Ejemplo n.º 5
0
        public static Uint32 Decode(IByteReader stream)
        {
            Uint32 decodedUint32 = new Uint32();

            decodedUint32.InnerValue = XdrEncoding.DecodeUInt32(stream);
            return(decodedUint32);
        }
Ejemplo n.º 6
0
 public ClientState(int id) : base()
 {
     m_playerStates = new PlayerHashMap(new Dictionary <int, common.data.PlayerState>());
     Tick           = new Uint32(0);
     PlayerGUID     = id;
     InitSerializableMembers(m_playerStates, Tick);
 }
Ejemplo n.º 7
0
        public static Transaction Decode(XdrDataInputStream stream)
        {
            Transaction decodedTransaction = new Transaction();

            decodedTransaction.SourceAccount = AccountID.Decode(stream);
            decodedTransaction.Fee           = Uint32.Decode(stream);
            decodedTransaction.SeqNum        = SequenceNumber.Decode(stream);
            int TimeBoundsPresent = stream.ReadInt();

            if (TimeBoundsPresent != 0)
            {
                decodedTransaction.TimeBounds = TimeBounds.Decode(stream);
            }

            decodedTransaction.Memo = Memo.Decode(stream);
            int operationssize = stream.ReadInt();

            decodedTransaction.Operations = new Operation[operationssize];

            for (int i = 0; i < operationssize; i++)
            {
                decodedTransaction.Operations[i] = Operation.Decode(stream);
            }

            decodedTransaction.Ext = TransactionExt.Decode(stream);
            return(decodedTransaction);
        }
Ejemplo n.º 8
0
        public static AccountEntry Decode(XdrDataInputStream stream)
        {
            var decodedAccountEntry = new AccountEntry();

            decodedAccountEntry.AccountID     = AccountID.Decode(stream);
            decodedAccountEntry.Balance       = Int64.Decode(stream);
            decodedAccountEntry.SeqNum        = SequenceNumber.Decode(stream);
            decodedAccountEntry.NumSubEntries = Uint32.Decode(stream);
            var InflationDestPresent = stream.ReadInt();

            if (InflationDestPresent != 0)
            {
                decodedAccountEntry.InflationDest = AccountID.Decode(stream);
            }
            decodedAccountEntry.Flags      = Uint32.Decode(stream);
            decodedAccountEntry.HomeDomain = String32.Decode(stream);
            decodedAccountEntry.Thresholds = Thresholds.Decode(stream);
            var signerssize = stream.ReadInt();

            decodedAccountEntry.Signers = new Signer[signerssize];
            for (var i = 0; i < signerssize; i++)
            {
                decodedAccountEntry.Signers[i] = Signer.Decode(stream);
            }
            decodedAccountEntry.Ext = AccountEntryExt.Decode(stream);
            return(decodedAccountEntry);
        }
Ejemplo n.º 9
0
        public static void Encode(IByteWriter stream, AccountEntry encodedAccountEntry)
        {
            AccountID.Encode(stream, encodedAccountEntry.AccountID);
            Int64.Encode(stream, encodedAccountEntry.Balance);
            SequenceNumber.Encode(stream, encodedAccountEntry.SeqNum);
            Uint32.Encode(stream, encodedAccountEntry.NumSubEntries);
            if (encodedAccountEntry.InflationDest != null)
            {
                XdrEncoding.EncodeInt32(1, stream);
                AccountID.Encode(stream, encodedAccountEntry.InflationDest);
            }
            else
            {
                XdrEncoding.EncodeInt32(0, stream);
            }
            Uint32.Encode(stream, encodedAccountEntry.Flags);
            String32.Encode(stream, encodedAccountEntry.HomeDomain);
            Thresholds.Encode(stream, encodedAccountEntry.Thresholds);
            int signerssize = encodedAccountEntry.Signers.Length;

            XdrEncoding.EncodeInt32(signerssize, stream);
            for (int i = 0; i < signerssize; i++)
            {
                Signer.Encode(stream, encodedAccountEntry.Signers[i]);
            }
            AccountEntryExt.Encode(stream, encodedAccountEntry.Ext);
        }
Ejemplo n.º 10
0
        public static void Encode(XdrDataOutputStream stream, AccountEntry encodedAccountEntry)
        {
            AccountID.Encode(stream, encodedAccountEntry.AccountID);
            Int64.Encode(stream, encodedAccountEntry.Balance);
            SequenceNumber.Encode(stream, encodedAccountEntry.SeqNum);
            Uint32.Encode(stream, encodedAccountEntry.NumSubEntries);

            if (encodedAccountEntry.InflationDest != null)
            {
                stream.WriteInt(1);
                AccountID.Encode(stream, encodedAccountEntry.InflationDest);
            }
            else
            {
                stream.WriteInt(0);
            }

            Uint32.Encode(stream, encodedAccountEntry.Flags);
            String32.Encode(stream, encodedAccountEntry.HomeDomain);
            Thresholds.Encode(stream, encodedAccountEntry.Thresholds);
            int signerssize = encodedAccountEntry.Signers.Length;

            stream.WriteInt(signerssize);

            for (int i = 0; i < signerssize; i++)
            {
                Signer.Encode(stream, encodedAccountEntry.Signers[i]);
            }

            AccountEntryExt.Encode(stream, encodedAccountEntry.Ext);
        }
Ejemplo n.º 11
0
        public static Uint32 Decode(XdrDataInputStream stream)
        {
            var decodedUint32 = new Uint32();

            decodedUint32.InnerValue = stream.ReadInt();
            return(decodedUint32);
        }
Ejemplo n.º 12
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] = Decode(stream);
            }

            return(decodedSCPQuorumSet);
        }
Ejemplo n.º 13
0
        public static AccountEntry Decode(IByteReader stream)
        {
            AccountEntry decodedAccountEntry = new AccountEntry();

            decodedAccountEntry.AccountID     = AccountID.Decode(stream);
            decodedAccountEntry.Balance       = Int64.Decode(stream);
            decodedAccountEntry.SeqNum        = SequenceNumber.Decode(stream);
            decodedAccountEntry.NumSubEntries = Uint32.Decode(stream);
            int inflationDestPresent = XdrEncoding.DecodeInt32(stream);

            if (inflationDestPresent != 0)
            {
                decodedAccountEntry.InflationDest = AccountID.Decode(stream);
            }
            decodedAccountEntry.Flags      = Uint32.Decode(stream);
            decodedAccountEntry.HomeDomain = String32.Decode(stream);
            decodedAccountEntry.Thresholds = Thresholds.Decode(stream);
            int signerssize = XdrEncoding.DecodeInt32(stream);

            decodedAccountEntry.Signers = new Signer[signerssize];
            for (int i = 0; i < signerssize; i++)
            {
                decodedAccountEntry.Signers[i] = Signer.Decode(stream);
            }
            decodedAccountEntry.Ext = AccountEntryExt.Decode(stream);
            return(decodedAccountEntry);
        }
Ejemplo n.º 14
0
 public static void Encode(XdrDataOutputStream stream, SCPStatementPrepare encodedSCPStatementPrepare)
 {
     Hash.Encode(stream, encodedSCPStatementPrepare.QuorumSetHash);
     SCPBallot.Encode(stream, encodedSCPStatementPrepare.Ballot);
     if (encodedSCPStatementPrepare.Prepared != null)
     {
         stream.WriteInt(1);
         SCPBallot.Encode(stream, encodedSCPStatementPrepare.Prepared);
     }
     else
     {
         stream.WriteInt(0);
     }
     if (encodedSCPStatementPrepare.PreparedPrime != null)
     {
         stream.WriteInt(1);
         SCPBallot.Encode(stream, encodedSCPStatementPrepare.PreparedPrime);
     }
     else
     {
         stream.WriteInt(0);
     }
     Uint32.Encode(stream, encodedSCPStatementPrepare.NC);
     Uint32.Encode(stream, encodedSCPStatementPrepare.NH);
 }
Ejemplo n.º 15
0
 public static void Encode(IByteWriter stream, SCPStatementPrepare encodedSCPStatementPrepare)
 {
     Hash.Encode(stream, encodedSCPStatementPrepare.QuorumSetHash);
     SCPBallot.Encode(stream, encodedSCPStatementPrepare.Ballot);
     if (encodedSCPStatementPrepare.Prepared != null)
     {
         XdrEncoding.EncodeInt32(1, stream);
         SCPBallot.Encode(stream, encodedSCPStatementPrepare.Prepared);
     }
     else
     {
         XdrEncoding.EncodeInt32(0, stream);
     }
     if (encodedSCPStatementPrepare.PreparedPrime != null)
     {
         XdrEncoding.EncodeInt32(1, stream);
         SCPBallot.Encode(stream, encodedSCPStatementPrepare.PreparedPrime);
     }
     else
     {
         XdrEncoding.EncodeInt32(0, stream);
     }
     Uint32.Encode(stream, encodedSCPStatementPrepare.NC);
     Uint32.Encode(stream, encodedSCPStatementPrepare.NH);
 }
Ejemplo n.º 16
0
        /// <summary>
        /// </summary>
        /// <returns></returns>
        public new Type GetType()
        {
            switch (Type)
            {
            case 0x00:
            case 0x01:
                return(Uint8.GetType());

            case 0x02:
            case 0x03:
                return(Uint16.GetType());

            case 0x04:
            case 0x05:
                return(Uint32.GetType());

            case 0x06:
            case 0x07:
                return(Uint64.GetType());

            case 0x08:
                return(Ufloat.GetType());

            case 0x0A:
                return(Str.GetType());

            case 0x0B:
                return(Data.GetType());

            default:
                return(null);
            }
        }
Ejemplo n.º 17
0
 public static void Encode(XdrDataOutputStream stream,
                           SCPStatementExternalize encodedSCPStatementExternalize)
 {
     SCPBallot.Encode(stream, encodedSCPStatementExternalize.Commit);
     Uint32.Encode(stream, encodedSCPStatementExternalize.NH);
     Hash.Encode(stream, encodedSCPStatementExternalize.CommitQuorumSetHash);
 }
Ejemplo n.º 18
0
        public static LedgerHeader Decode(XdrDataInputStream stream)
        {
            var decodedLedgerHeader = new LedgerHeader();

            decodedLedgerHeader.LedgerVersion      = Uint32.Decode(stream);
            decodedLedgerHeader.PreviousLedgerHash = Hash.Decode(stream);
            decodedLedgerHeader.ScpValue           = StellarValue.Decode(stream);
            decodedLedgerHeader.TxSetResultHash    = Hash.Decode(stream);
            decodedLedgerHeader.BucketListHash     = Hash.Decode(stream);
            decodedLedgerHeader.LedgerSeq          = Uint32.Decode(stream);
            decodedLedgerHeader.TotalCoins         = Int64.Decode(stream);
            decodedLedgerHeader.FeePool            = Int64.Decode(stream);
            decodedLedgerHeader.InflationSeq       = Uint32.Decode(stream);
            decodedLedgerHeader.IdPool             = Uint64.Decode(stream);
            decodedLedgerHeader.BaseFee            = Uint32.Decode(stream);
            decodedLedgerHeader.BaseReserve        = Uint32.Decode(stream);
            decodedLedgerHeader.MaxTxSetSize       = Uint32.Decode(stream);
            var skipListsize = 4;

            decodedLedgerHeader.SkipList = new Hash[skipListsize];
            for (var i = 0; i < skipListsize; i++)
            {
                decodedLedgerHeader.SkipList[i] = Hash.Decode(stream);
            }
            decodedLedgerHeader.Ext = LedgerHeaderExt.Decode(stream);
            return(decodedLedgerHeader);
        }
Ejemplo n.º 19
0
        public static void Encode(XdrDataOutputStream stream, Transaction encodedTransaction)
        {
            AccountID.Encode(stream, encodedTransaction.SourceAccount);
            Uint32.Encode(stream, encodedTransaction.Fee);
            SequenceNumber.Encode(stream, encodedTransaction.SeqNum);

            if (encodedTransaction.TimeBounds != null)
            {
                stream.WriteInt(1);
                TimeBounds.Encode(stream, encodedTransaction.TimeBounds);
            }
            else
            {
                stream.WriteInt(0);
            }

            Memo.Encode(stream, encodedTransaction.Memo);
            int operationssize = encodedTransaction.Operations.Length;

            stream.WriteInt(operationssize);

            for (int i = 0; i < operationssize; i++)
            {
                Operation.Encode(stream, encodedTransaction.Operations[i]);
            }

            TransactionExt.Encode(stream, encodedTransaction.Ext);
        }
Ejemplo n.º 20
0
        public static SetOptionsOp Decode(XdrDataInputStream stream)
        {
            var decodedSetOptionsOp  = new SetOptionsOp();
            var InflationDestPresent = stream.ReadInt();

            if (InflationDestPresent != 0)
            {
                decodedSetOptionsOp.InflationDest = AccountID.Decode(stream);
            }
            var ClearFlagsPresent = stream.ReadInt();

            if (ClearFlagsPresent != 0)
            {
                decodedSetOptionsOp.ClearFlags = Uint32.Decode(stream);
            }
            var SetFlagsPresent = stream.ReadInt();

            if (SetFlagsPresent != 0)
            {
                decodedSetOptionsOp.SetFlags = Uint32.Decode(stream);
            }
            var MasterWeightPresent = stream.ReadInt();

            if (MasterWeightPresent != 0)
            {
                decodedSetOptionsOp.MasterWeight = Uint32.Decode(stream);
            }
            var LowThresholdPresent = stream.ReadInt();

            if (LowThresholdPresent != 0)
            {
                decodedSetOptionsOp.LowThreshold = Uint32.Decode(stream);
            }
            var MedThresholdPresent = stream.ReadInt();

            if (MedThresholdPresent != 0)
            {
                decodedSetOptionsOp.MedThreshold = Uint32.Decode(stream);
            }
            var HighThresholdPresent = stream.ReadInt();

            if (HighThresholdPresent != 0)
            {
                decodedSetOptionsOp.HighThreshold = Uint32.Decode(stream);
            }
            var HomeDomainPresent = stream.ReadInt();

            if (HomeDomainPresent != 0)
            {
                decodedSetOptionsOp.HomeDomain = String32.Decode(stream);
            }
            var SignerPresent = stream.ReadInt();

            if (SignerPresent != 0)
            {
                decodedSetOptionsOp.Signer = Signer.Decode(stream);
            }
            return(decodedSetOptionsOp);
        }
Ejemplo n.º 21
0
        public static SetOptionsOp Decode(IByteReader stream)
        {
            SetOptionsOp decodedSetOptionsOp  = new SetOptionsOp();
            int          inflationDestPresent = XdrEncoding.DecodeInt32(stream);

            if (inflationDestPresent != 0)
            {
                decodedSetOptionsOp.InflationDest = AccountID.Decode(stream);
            }
            int clearFlagsPresent = XdrEncoding.DecodeInt32(stream);

            if (clearFlagsPresent != 0)
            {
                decodedSetOptionsOp.ClearFlags = Uint32.Decode(stream);
            }
            int setFlagsPresent = XdrEncoding.DecodeInt32(stream);

            if (setFlagsPresent != 0)
            {
                decodedSetOptionsOp.SetFlags = Uint32.Decode(stream);
            }
            int masterWeightPresent = XdrEncoding.DecodeInt32(stream);

            if (masterWeightPresent != 0)
            {
                decodedSetOptionsOp.MasterWeight = Uint32.Decode(stream);
            }
            int lowThresholdPresent = XdrEncoding.DecodeInt32(stream);

            if (lowThresholdPresent != 0)
            {
                decodedSetOptionsOp.LowThreshold = Uint32.Decode(stream);
            }
            int medThresholdPresent = XdrEncoding.DecodeInt32(stream);

            if (medThresholdPresent != 0)
            {
                decodedSetOptionsOp.MedThreshold = Uint32.Decode(stream);
            }
            int highThresholdPresent = XdrEncoding.DecodeInt32(stream);

            if (highThresholdPresent != 0)
            {
                decodedSetOptionsOp.HighThreshold = Uint32.Decode(stream);
            }
            int homeDomainPresent = XdrEncoding.DecodeInt32(stream);

            if (homeDomainPresent != 0)
            {
                decodedSetOptionsOp.HomeDomain = String32.Decode(stream);
            }
            int signerPresent = XdrEncoding.DecodeInt32(stream);

            if (signerPresent != 0)
            {
                decodedSetOptionsOp.Signer = Signer.Decode(stream);
            }
            return(decodedSetOptionsOp);
        }
 public static void Encode(XdrDataOutputStream stream, SurveyRequestMessage encodedSurveyRequestMessage)
 {
     NodeID.Encode(stream, encodedSurveyRequestMessage.SurveyorPeerID);
     NodeID.Encode(stream, encodedSurveyRequestMessage.SurveyedPeerID);
     Uint32.Encode(stream, encodedSurveyRequestMessage.LedgerNum);
     Curve25519Public.Encode(stream, encodedSurveyRequestMessage.EncryptionKey);
     SurveyMessageCommandType.Encode(stream, encodedSurveyRequestMessage.CommandType);
 }
Ejemplo n.º 23
0
 public static void Encode(XdrDataOutputStream stream, SCPStatementConfirm encodedSCPStatementConfirm)
 {
     SCPBallot.Encode(stream, encodedSCPStatementConfirm.Ballot);
     Uint32.Encode(stream, encodedSCPStatementConfirm.NPrepared);
     Uint32.Encode(stream, encodedSCPStatementConfirm.NCommit);
     Uint32.Encode(stream, encodedSCPStatementConfirm.NH);
     Hash.Encode(stream, encodedSCPStatementConfirm.QuorumSetHash);
 }
Ejemplo n.º 24
0
        public static Signer Decode(XdrDataInputStream stream)
        {
            var decodedSigner = new Signer();

            decodedSigner.Key    = SignerKey.Decode(stream);
            decodedSigner.Weight = Uint32.Decode(stream);
            return(decodedSigner);
        }
Ejemplo n.º 25
0
 public static void Encode(IByteWriter stream, SCPStatementConfirm encodedSCPStatementConfirm)
 {
     SCPBallot.Encode(stream, encodedSCPStatementConfirm.Ballot);
     Uint32.Encode(stream, encodedSCPStatementConfirm.NPrepared);
     Uint32.Encode(stream, encodedSCPStatementConfirm.NCommit);
     Uint32.Encode(stream, encodedSCPStatementConfirm.NH);
     Hash.Encode(stream, encodedSCPStatementConfirm.QuorumSetHash);
 }
Ejemplo n.º 26
0
        public static Signer Decode(IByteReader stream)
        {
            Signer decodedSigner = new Signer();

            decodedSigner.Key    = SignerKey.Decode(stream);
            decodedSigner.Weight = Uint32.Decode(stream);
            return(decodedSigner);
        }
Ejemplo n.º 27
0
        public static SCPBallot Decode(XdrDataInputStream stream)
        {
            SCPBallot decodedSCPBallot = new SCPBallot();

            decodedSCPBallot.Counter = Uint32.Decode(stream);
            decodedSCPBallot.Value   = Value.Decode(stream);
            return(decodedSCPBallot);
        }
Ejemplo n.º 28
0
        public static BucketMetadata Decode(XdrDataInputStream stream)
        {
            BucketMetadata decodedBucketMetadata = new BucketMetadata();

            decodedBucketMetadata.LedgerVersion = Uint32.Decode(stream);
            decodedBucketMetadata.Ext           = BucketMetadataExt.Decode(stream);
            return(decodedBucketMetadata);
        }
Ejemplo n.º 29
0
        public static Signer Decode(IByteReader stream)
        {
            Signer decodedSigner = new Signer();

            decodedSigner.PubKey = AccountID.Decode(stream);
            decodedSigner.Weight = Uint32.Decode(stream);
            return(decodedSigner);
        }
Ejemplo n.º 30
0
        public static SCPBallot Decode(IByteReader stream)
        {
            SCPBallot decodedSCPBallot = new SCPBallot();

            decodedSCPBallot.Counter = Uint32.Decode(stream);
            decodedSCPBallot.Value   = Value.Decode(stream);
            return(decodedSCPBallot);
        }
Ejemplo n.º 31
0
 public static void Encode(IByteWriter stream, Uint32  encodedUint32) {
 XdrEncoding.EncodeUInt32(encodedUint32.InnerValue, stream);
 }
Ejemplo n.º 32
0
 public static Uint32 Decode(IByteReader stream) {
   Uint32 decodedUint32 = new Uint32();
 decodedUint32.InnerValue = XdrEncoding.DecodeUInt32(stream);
   return decodedUint32;
 }