mirror of
https://github.com/kvazar-network/keva-stratum.git
synced 2025-01-13 08:37:57 +00:00
fixed hash for block explorer link
This commit is contained in:
parent
6053c2540c
commit
2d0fadd8b8
@ -53,5 +53,5 @@ func Hash(blob []byte, fast bool, height int, seedHash string) []byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func FastHash(blob []byte) []byte {
|
func FastHash(blob []byte) []byte {
|
||||||
return Hash(append([]byte{byte(len(blob))}, blob...), true, 0, "")
|
return Hash(blob, true, 0, "")
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,7 @@ func (m *Miner) processShare(s *StratumServer, cs *Session, job *Job, t *BlockTe
|
|||||||
if len(convertedBlob) == 0 {
|
if len(convertedBlob) == 0 {
|
||||||
convertedBlob = cnutil.ConvertBlob(shareBuff)
|
convertedBlob = cnutil.ConvertBlob(shareBuff)
|
||||||
}
|
}
|
||||||
blockFastHash := hex.EncodeToString(cnutil.FastHash(convertedBlob))
|
blockFastHash := hex.EncodeToString(util.ReverseBytes(cnutil.FastHash(convertedBlob)))
|
||||||
now := util.MakeTimestamp()
|
now := util.MakeTimestamp()
|
||||||
roundShares := atomic.SwapInt64(&s.roundShares, 0)
|
roundShares := atomic.SwapInt64(&s.roundShares, 0)
|
||||||
ratio := float64(roundShares) / float64(t.diffInt64)
|
ratio := float64(roundShares) / float64(t.diffInt64)
|
||||||
|
@ -29,13 +29,13 @@ func GetTargetHex(diff int64) string {
|
|||||||
diffBuff := new(big.Int).Div(Diff1, big.NewInt(diff)).Bytes()
|
diffBuff := new(big.Int).Div(Diff1, big.NewInt(diff)).Bytes()
|
||||||
copy(padded[32-len(diffBuff):], diffBuff)
|
copy(padded[32-len(diffBuff):], diffBuff)
|
||||||
buff := padded[0:4]
|
buff := padded[0:4]
|
||||||
targetHex := hex.EncodeToString(reverse(buff))
|
targetHex := hex.EncodeToString(ReverseBytes(buff))
|
||||||
return targetHex
|
return targetHex
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetHashDifficulty(hashBytes []byte) (*big.Int, bool) {
|
func GetHashDifficulty(hashBytes []byte) (*big.Int, bool) {
|
||||||
diff := new(big.Int)
|
diff := new(big.Int)
|
||||||
diff.SetBytes(reverse(hashBytes))
|
diff.SetBytes(ReverseBytes(hashBytes))
|
||||||
|
|
||||||
// Check for broken result, empty string or zero hex value
|
// Check for broken result, empty string or zero hex value
|
||||||
if diff.Cmp(new(big.Int)) == 0 {
|
if diff.Cmp(new(big.Int)) == 0 {
|
||||||
@ -75,7 +75,7 @@ func ValidateAddress(addy string, poolAddy string) bool {
|
|||||||
return cnutil.ValidateAddress(addy)
|
return cnutil.ValidateAddress(addy)
|
||||||
}
|
}
|
||||||
|
|
||||||
func reverse(src []byte) []byte {
|
func ReverseBytes(src []byte) []byte {
|
||||||
dst := make([]byte, len(src))
|
dst := make([]byte, len(src))
|
||||||
for i := len(src); i > 0; i-- {
|
for i := len(src); i > 0; i-- {
|
||||||
dst[len(src)-i] = src[i-1]
|
dst[len(src)-i] = src[i-1]
|
||||||
|
Loading…
Reference in New Issue
Block a user