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

            try  { mMutex.WaitOne(5000); } catch (Exception) { }
            RegisterDeviceWithShare(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);
                MainForm.Logger("Device #" + aDevice.DeviceIndex + " submitted a share.");
            }
            catch (Exception ex)
            {
                MainForm.Logger("Failed to submit share: " + ex.Message + ex.StackTrace);
                try { mMutex.ReleaseMutex(); } catch (Exception) { }
                Reconnect();
            }
            try  { mMutex.ReleaseMutex(); } catch (Exception) { }
        }
Beispiel #2
0
        public override void Submit(EthashStratum.Job job, UInt64 output)
        {
            if (Stopped)
            {
                return;
            }

            mMutex.WaitOne();
            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));
                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
                      } }
                });
                mStreamWriter.Write(message + "\n");
                mStreamWriter.Flush();
            }
            catch (Exception ex)
            {
                MainForm.Logger("Failed to submit share: " + ex.Message + ex.StackTrace);
            }
            mMutex.ReleaseMutex();
        }