private void _process_OutputDataReceived(object sender, DataReceivedEventArgs e)
        {
            if (string.IsNullOrEmpty(e.Data))
            {
                return;
            }

            //hash rate
            if (e.Data.StartsWith("["))
            {
                var regexMatches = _rateRegex.Matches(e.Data);

                if (regexMatches.Count > 0)
                {
                    var rate  = regexMatches[0].Groups[1].Value;
                    var total = long.Parse(regexMatches[1].Groups[1].Value.Remove(0, 6));

                    if (HashRateChanged != null)
                    {
                        HashRateChanged(this, new VanitygenUpdateEventArgs(rate, total));
                    }
                }
            }

            //generation result
            else if (e.Data.StartsWith("Pattern") || _workingPattern != null)
            {
                var split = e.Data.Split(':');
                var info  = split[0];
                var value = split[1].Trim();

                if (info == "Pattern")
                {
                    _workingPattern = value;
                }
                else if (info == "Address")
                {
                    _workingAddress = value;
                }
                else if (info == "Privkey")
                {
                    _workingKey = value;

                    var result = new VanitygenResult(_workingPattern, _workingAddress, _workingKey);

                    if (AddressGenerated != null)
                    {
                        AddressGenerated(this, new AddressGeneratedEventArgs(result));
                    }

                    _workingPattern = _workingAddress = _workingKey = null;
                }
            }
        }
Exemple #2
0
 public AddressGeneratedEventArgs(VanitygenResult result)
 {
     Result = result;
 }