diff --git a/cnutil/cnutil.go b/cnutil/cnutil.go index 43110e9..7170d48 100644 --- a/cnutil/cnutil.go +++ b/cnutil/cnutil.go @@ -53,5 +53,5 @@ func Hash(blob []byte, fast bool, height int, seedHash string) []byte { } func FastHash(blob []byte) []byte { - return Hash(append([]byte{byte(len(blob))}, blob...), true, 0, "") + return Hash(blob, true, 0, "") } diff --git a/stratum/miner.go b/stratum/miner.go index 3f5a36f..0f89475 100644 --- a/stratum/miner.go +++ b/stratum/miner.go @@ -204,7 +204,7 @@ func (m *Miner) processShare(s *StratumServer, cs *Session, job *Job, t *BlockTe if len(convertedBlob) == 0 { convertedBlob = cnutil.ConvertBlob(shareBuff) } - blockFastHash := hex.EncodeToString(cnutil.FastHash(convertedBlob)) + blockFastHash := hex.EncodeToString(util.ReverseBytes(cnutil.FastHash(convertedBlob))) now := util.MakeTimestamp() roundShares := atomic.SwapInt64(&s.roundShares, 0) ratio := float64(roundShares) / float64(t.diffInt64) diff --git a/util/util.go b/util/util.go index 1f9938b..28ce699 100644 --- a/util/util.go +++ b/util/util.go @@ -29,13 +29,13 @@ func GetTargetHex(diff int64) string { diffBuff := new(big.Int).Div(Diff1, big.NewInt(diff)).Bytes() copy(padded[32-len(diffBuff):], diffBuff) buff := padded[0:4] - targetHex := hex.EncodeToString(reverse(buff)) + targetHex := hex.EncodeToString(ReverseBytes(buff)) return targetHex } func GetHashDifficulty(hashBytes []byte) (*big.Int, bool) { diff := new(big.Int) - diff.SetBytes(reverse(hashBytes)) + diff.SetBytes(ReverseBytes(hashBytes)) // Check for broken result, empty string or zero hex value if diff.Cmp(new(big.Int)) == 0 { @@ -75,7 +75,7 @@ func ValidateAddress(addy string, poolAddy string) bool { return cnutil.ValidateAddress(addy) } -func reverse(src []byte) []byte { +func ReverseBytes(src []byte) []byte { dst := make([]byte, len(src)) for i := len(src); i > 0; i-- { dst[len(src)-i] = src[i-1]