Пример #1
0
        private bool IsClickAll = false; //按钮 content 用
        /***********************************************方法***********************************************/
        //窗口初始化
        public DO15(CT2.CIoNode ioData)
        {
            InitializeComponent();

            UpdateInner(ioData);
            NID.Text = IOData.m_nodeID.ToString();
            HexValue.SetBinding(TextBlock.TextProperty, new Binding("HexValue")
            {
                Source = UIData
            });
        }
Пример #2
0
        public void GenderTest()
        {
            var genderAttr = AttributeBuilder.Create("Gender")
                             .Salted(false).SetPosition(2).SetSize(1).SetCreation(2).SetMaxRange(2).Build();

            var dict = new Dictionary <int, int>();

            foreach (var b1 in Base58Encoding.Digits.ToCharArray())
            {
                foreach (var b2 in Base58Encoding.Digits.ToCharArray())
                {
                    var addr             = "M" + b1 + b2 + "KtKS3AeNuRFWE5Qj9tFiNAahWvQMTiz";
                    var pubMogAddressHex = HexHashUtil.ByteArrayToString(Base58Encoding.Decode(addr));
                    var hexValue         =
                        new HexValue(
                            new Shift(0,
                                      1530914381,
                                      pubMogAddressHex,
                                      7234,
                                      "00000000090d6c6b058227bb61ca2915a84998703d4444cc2641e6a0da4ba37e",
                                      2,
                                      "163d2e383c77765232be1d9ed5e06749a814de49b4c0a8aebf324c0e9e2fd1cf",
                                      1.00m,
                                      0.0001m));

                    genderAttr.CreateValue(hexValue);

                    var value    = genderAttr.GetValue();
                    var orgValue = HexHashUtil.GetHexVal(pubMogAddressHex[1]);
                    if (dict.TryGetValue(value, out var count))
                    {
                        dict[value] = count + 1;
                    }
                    else
                    {
                        dict.Add(value, 1);
                    }
                }
            }

            Assert.Equal(2, dict.Count);
            var enumerator = dict.Keys.GetEnumerator();

            enumerator.MoveNext();
            Assert.Equal(1, enumerator.Current);
            enumerator.MoveNext();
            Assert.Equal(0, enumerator.Current);
            Assert.Equal(1692, dict[0]);
            Assert.Equal(1672, dict[1]);
        }
Пример #3
0
        public void GenerateNameTest()
        {
            var hexValue =
                new HexValue(
                    new Shift(0,
                              1530914381,
                              "32ad9e02792599dfdb6a9d0bc0b924da23bd96b1b7eb4f0a68",
                              7234,
                              "00000000090d6c6b058227bb61ca2915a84998703d4444cc2641e6a0da4ba37e",
                              2,
                              "163d2e383c77765232be1d9ed5e06749a814de49b4c0a8aebf324c0e9e2fd1cf",
                              1.00m,
                              0.0001m));

            Assert.Equal("Vihiryne", NameGen.GenerateName(hexValue));
        }
Пример #4
0
        public static string GenerateName(HexValue hexValue)
        {
            var minLength = GetMinLength(hexValue.UnSalted, 3, 9);

            string[] consonants = { "b", "c", "ck", "d", "f", "g", "h", "j", "k", "l", "m", "l", "n", "p", "q", "r", "s", "sh", "zh", "t", "v", "w", "x" };
            string[] vowels     = { "a", "e", "i", "o", "u", "ae", "y" };
            var      name       = "";

            if (HexHashUtil.TryHexPosConversion(4, 2, hexValue.UnSalted, out var seedValues))
            {
                name += consonants[(int)seedValues % consonants.Length];
            }

            if (HexHashUtil.TryHexPosConversion(6, 2, hexValue.UnSalted, out seedValues))
            {
                name += vowels[(int)seedValues % vowels.Length];
            }

            var ind          = 8;
            var consonantNow = true;

            while (name.Length < minLength)
            {
                if (consonantNow && HexHashUtil.TryHexPosConversion(ind, 2, hexValue.UnSalted, out seedValues))
                {
                    name += consonants[(int)seedValues % consonants.Length];
                }
                else if (HexHashUtil.TryHexPosConversion(ind, 2, hexValue.UnSalted, out seedValues))
                {
                    name += vowels[(int)seedValues % vowels.Length];
                }
                else
                {
                    Log.Error("Generating names seems currently troublesome!");
                }

                consonantNow = !consonantNow;
                ind         += 2;
            }

            return(name.First().ToString().ToUpper() + name.Substring(1));
        }
Пример #5
0
 public byte[] ToHexByteArray()
 {
     return(HexValue.HexToByteArray());
 }
Пример #6
0
        //eth_getTransactionCount

        /// <summary>
        /// Returns the receipt of a transaction by transaction hash. Note that the receipt is not available for pending transactions.
        /// </summary>
        /// <param name="hash"></param>
        /// <param name="b"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public Task <JsonRpcResponse <GetTransactionReceiptResult> > GetTransactionReceiptAsync(HexValue hash, CancellationToken token)
        {
            return(CustomGetRequestAsync <GetTransactionReceiptResult>("eth_getTransactionReceipt", new object[] { hash }, token));
        }
Пример #7
0
        //eth_getStorageAt
        //    eth_getTransactionByBlockHashAndIndex
        //eth_getTransactionByBlockNumberAndIndex

        /// <summary>
        /// Returns information about a transaction for a given hash.
        /// </summary>
        /// <param name="hash"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public Task <JsonRpcResponse <Transaction> > GetTransactionByHashAsync(HexValue hash, CancellationToken token)
        {
            return(CustomGetRequestAsync <Transaction>("eth_getTransactionByHash", new object[] { hash }, token));
        }