Example #1
0
        override public void Submit(Device aDevice, EthashStratum.Job job, UInt64 output)
        {
            if (Stopped)
            {
                return;
            }

            try  { mMutex.WaitOne(5000); } catch (Exception) { }
            ReportSubmittedShare(aDevice);
            try
            {
                String stringNonce
                    = ((PoolExtranonce.Length == 0) ? (String.Format("{7:x2}{6:x2}{5:x2}{4:x2}{3:x2}{2:x2}{1:x2}{0:x2}", ((output >> 0) & 0xff), ((output >> 8) & 0xff), ((output >> 16) & 0xff), ((output >> 24) & 0xff), ((output >> 32) & 0xff), ((output >> 40) & 0xff), ((output >> 48) & 0xff), ((output >> 56) & 0xff))) :
                       (PoolExtranonce.Length == 2) ? (String.Format("{6:x2}{5:x2}{4:x2}{3:x2}{2:x2}{1:x2}{0:x2}", ((output >> 0) & 0xff), ((output >> 8) & 0xff), ((output >> 16) & 0xff), ((output >> 24) & 0xff), ((output >> 32) & 0xff), ((output >> 40) & 0xff), ((output >> 48) & 0xff))) :
                       (PoolExtranonce.Length == 4) ? (String.Format("{5:x2}{4:x2}{3:x2}{2:x2}{1:x2}{0:x2}", ((output >> 0) & 0xff), ((output >> 8) & 0xff), ((output >> 16) & 0xff), ((output >> 24) & 0xff), ((output >> 32) & 0xff), ((output >> 40) & 0xff))) :
                       (String.Format("{4:x2}{3:x2}{2:x2}{1:x2}{0:x2}", ((output >> 0) & 0xff), ((output >> 8) & 0xff), ((output >> 16) & 0xff), ((output >> 24) & 0xff), ((output >> 32) & 0xff))));
                String message = JsonConvert.SerializeObject(new Dictionary <string, Object> {
                    { "id", mJsonRPCMessageID },
                    { "method", "mining.submit" },
                    { "params", new List <string> {
                          Username,
                          job.ID,
                          stringNonce
                      } }
                });
                WriteLine(message);
                ++mJsonRPCMessageID;
            }
            catch (Exception ex) {
                Program.Logger("Failed to submit share: " + ex.Message + "\nReconnecting to the server...");
                Reconnect();
            }
            try  { mMutex.ReleaseMutex(); } catch (Exception) { }
        }
Example #2
0
        override public void Submit(Device aDevice, EthashStratum.Job job, UInt64 output)
        {
            if (Stopped)
            {
                return;
            }

            try  { mMutex.WaitOne(5000); } catch (Exception) { }
            ReportSubmittedShare(aDevice);
            try
            {
                String stringNonce
                    = String.Format("{7:x2}{6:x2}{5:x2}{4:x2}{3:x2}{2:x2}{1:x2}{0:x2}",
                                    ((output >> 0) & 0xff),
                                    ((output >> 8) & 0xff),
                                    ((output >> 16) & 0xff),
                                    ((output >> 24) & 0xff),
                                    ((output >> 32) & 0xff),
                                    ((output >> 40) & 0xff),
                                    ((output >> 48) & 0xff),
                                    ((output >> 56) & 0xff));
                mShareIDs.Add(mJsonRPCMessageID.ToString());
                String message = JsonConvert.SerializeObject(new Dictionary <string, Object> {
                    { "id", mJsonRPCMessageID },
                    { "jsonrpc", "2.0" },
                    { "method", "eth_submitWork" },
                    { "params", new List <string> {
                          "0x" + stringNonce,
                          "0x" + job.Headerhash,        // The header's pow-hash (256 bits)
                          "0x" + job.GetMixHash(output) // mix digest
                      } }
                });
                WriteLine(message);
                ++mJsonRPCMessageID;
            }
            catch (Exception ex) {
                Program.Logger("Failed to submit share: " + ex.Message + "\nReconnecting to the server...");
                Reconnect();
            }
            try  { mMutex.ReleaseMutex(); } catch (Exception) { }
        }