コード例 #1
0
 public bool Equals(RawTransaction other) => Nonce == other.Nonce &&
 Signer.SequenceEqual(other.Signer) &&
 PublicKey.SequenceEqual(other.PublicKey) &&
 GenesisHash.SequenceEqual(other.GenesisHash) &&
 UpdatedAddresses.SequenceEqual(
     other.UpdatedAddresses) &&
 Timestamp == other.Timestamp &&
 Signature.SequenceEqual(other.Signature) &&
 Actions.SequenceEqual(other.Actions);
コード例 #2
0
        public override string ToString()
        {
            string updatedAddresses = string.Join(
                string.Empty,
                UpdatedAddresses.Select(a => "\n    " + ByteUtil.Hex(a))
                );

            return($@"{nameof(RawTransaction)}
  {nameof(Signer)} = {ByteUtil.Hex(Signer)}
  {nameof(PublicKey)} = {ByteUtil.Hex(PublicKey)}
  {nameof(UpdatedAddresses)} = {updatedAddresses}
  {nameof(Timestamp)} = {Timestamp}
  {nameof(Signature)} = {ByteUtil.Hex(Signature)}");
        }
コード例 #3
0
        public override string ToString()
        {
            string updatedAddresses = string.Join(
                string.Empty,
                UpdatedAddresses.Select(a => "\n    " + ByteUtil.Hex(a.ToArray()))
                );

            return($@"{nameof(RawTransaction)}
  {nameof(Nonce)} = {Nonce.ToString(CultureInfo.InvariantCulture)}
  {nameof(Signer)} = {ByteUtil.Hex(Signer.ToArray())}
  {nameof(PublicKey)} = {ByteUtil.Hex(PublicKey.ToArray())}
  {nameof(UpdatedAddresses)} = {updatedAddresses}
  {nameof(Timestamp)} = {Timestamp}
  {nameof(Signature)} = {ByteUtil.Hex(Signature.ToArray())}");
        }
コード例 #4
0
        public bool Equals(RawTransaction other)
        {
            bool eq = Signer.SequenceEqual(other.Signer) &&
                      PublicKey.SequenceEqual(other.PublicKey) &&
                      UpdatedAddresses.SequenceEqual(other.UpdatedAddresses) &&
                      Timestamp == other.Timestamp &&
                      Actions.SequenceEqual(other.Actions);

            if (Signature == null)
            {
                return(eq && other.Signature == null);
            }
            else
            {
                return(eq && Signature.SequenceEqual(other.Signature));
            }
        }
コード例 #5
0
        public virtual bool SetData(int address, byte[] data)
        {
            if ((data == null) || (address < 0) || (PageSize <= 0))
            {
                return(false);
            }

            bool updated = false;

            if (!Pages.ContainsKey(address))
            {
                updated = true;
            }
            else
            {
                byte[] old_data = Pages[address];

                Logger.Trace("Page " + address + ": current value is " + BinConvert.ToHex(old_data));

                if (old_data.Length != data.Length)
                {
                    return(false);
                }
                for (int i = 0; i < old_data.Length; i++)
                {
                    if (old_data[i] != data[i])
                    {
                        updated = true;
                    }
                }
            }

            if (updated)
            {
                Logger.Trace("New content for page " + address + ": " + BinConvert.ToHex(data));

                Pages[address] = data;
                if (UpdatedAddresses == null)
                {
                    UpdatedAddresses = new List <int>();
                }
                UpdatedAddresses.Add(address);
            }

            return(true);
        }
コード例 #6
0
        internal RawTransaction ToRawTransaction(bool includeSign)
        {
            var rawTx = new RawTransaction(
                nonce: Nonce,
                signer: Signer.ByteArray,
                updatedAddresses: UpdatedAddresses.Select(a =>
                                                          a.ByteArray).ToImmutableArray(),
                publicKey: PublicKey.Format(false).ToImmutableArray(),
                timestamp: Timestamp.ToString(TimestampFormat, CultureInfo.InvariantCulture),
                actions: Actions.Select(a => a.PlainValue)
                );

            if (includeSign)
            {
                rawTx = rawTx.AddSignature(Signature);
            }

            return(rawTx);
        }
コード例 #7
0
ファイル: RawTransaction.cs プロジェクト: eiuapp/libplanet
        public Bencodex.Types.Dictionary ToBencodex()
        {
            var updatedAddresses =
                UpdatedAddresses.Select(addr => (IValue)(Binary)addr.ToArray());
            var dict = Bencodex.Types.Dictionary.Empty
                       .Add(NonceKey, Nonce)
                       .Add(SignerKey, Signer.ToArray())
                       .Add(UpdatedAddressesKey, updatedAddresses)
                       .Add(PublicKeyKey, PublicKey.ToArray())
                       .Add(TimestampKey, Timestamp)
                       .Add(ActionsKey, Actions);

            if (Signature != ImmutableArray <byte> .Empty)
            {
                dict = dict.Add(SignatureKey, Signature.ToArray());
            }

            return(dict);
        }
コード例 #8
0
        internal RawTransaction ToRawTransaction(bool includeSign)
        {
            var rawTx = new RawTransaction(
                signer: Signer.ToByteArray(),
                updatedAddresses: UpdatedAddresses.Select(a =>
                                                          a.ToByteArray()).ToArray(),
                publicKey: PublicKey.Format(false),
                timestamp: Timestamp.ToString(TimestampFormat),
                actions: Actions.Select(a =>
                                        a.PlainValue.ToDictionary(
                                            kv => kv.Key,
                                            kv => kv.Value
                                            )
                                        )
                );

            if (includeSign)
            {
                rawTx = rawTx.AddSignature(Signature);
            }

            return(rawTx);
        }