Browse Source

fixed hash for block explorer link

master
canrnd 3 years ago
parent
commit
2d0fadd8b8
  1. 2
      cnutil/cnutil.go
  2. 2
      stratum/miner.go
  3. 6
      util/util.go

2
cnutil/cnutil.go

@ -53,5 +53,5 @@ func Hash(blob []byte, fast bool, height int, seedHash string) []byte { @@ -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, "")
}

2
stratum/miner.go

@ -204,7 +204,7 @@ func (m *Miner) processShare(s *StratumServer, cs *Session, job *Job, t *BlockTe @@ -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)

6
util/util.go

@ -29,13 +29,13 @@ func GetTargetHex(diff int64) string { @@ -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 { @@ -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]

Loading…
Cancel
Save