From a44de4c59f243d40daec5b6e3a828174540d07a2 Mon Sep 17 00:00:00 2001 From: yuriy0803 <68668177+yuriy0803@users.noreply.github.com> Date: Tue, 18 Jul 2023 19:28:03 +0200 Subject: [PATCH] Update stratum.go With the provided code snippet, the getNotificationResponse function will now include additional logic to handle the "mining.notify" response differently based on the stratum mode. For regular stratum mode (EthProxy), it will return the initial response with "EthereumStratum/1.0.0" and the extranonce. For NiceHash stratum mode, it will construct the response using data from the current block template (t) and return the appropriate response for NiceHash miners. Please note that the getNotificationResponse function is used in the handleTCPMessage function when handling "mining.subscribe" requests for NiceHash mode. Make sure the rest of the code is properly set up to handle NiceHash stratum mode based on your specific requirements. Remember to integrate this code into your existing Go codebase and test it thoroughly to ensure it works as expected. If you have any further questions or need additional assistance, feel free to ask! --- proxy/stratum.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/proxy/stratum.go b/proxy/stratum.go index 4b9ff9d..d412867 100644 --- a/proxy/stratum.go +++ b/proxy/stratum.go @@ -640,5 +640,26 @@ func (cs *Session) getNotificationResponse(s *ProxyServer) interface{} { result[0] = []string{"mining.notify", randomHex(16), "EthereumStratum/1.0.0"} result[1] = cs.Extranonce + // Additional response data for NiceHash stratum mode + if cs.stratumMode() == NiceHash { + t := s.currentBlockTemplate() + if t != nil { + // Construct the response for NiceHash "mining.notify" + jobID := randomHex(8) + seedHash := t.Seed + headerHash := t.Header + height := util.ToHex1(int64(t.Height)) + // TO DO: Clean up the response structure based on actual data in "t" + + result = []interface{}{ + "mining.notify", + jobID, + seedHash, + headerHash, + height, + } + } + } + return result }