mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-05-23 07:16:47 +00:00

* Increase size of reachability cache * Change DomainHash to struct with unexported hashArray * Fixing compilation errors stemming from new DomainHash structure * Remove obsolete Read/WriteElement methods in appmessage * Fix all tests * Fix all tests * Add comments * A few renamings * go mod tidy
22 lines
535 B
Go
22 lines
535 B
Go
package hashes
|
|
|
|
import (
|
|
"math/big"
|
|
|
|
"github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
|
|
)
|
|
|
|
// ToBig converts a externalapi.DomainHash into a big.Int that can be used to
|
|
// perform math comparisons.
|
|
func ToBig(hash *externalapi.DomainHash) *big.Int {
|
|
// A Hash is in little-endian, but the big package wants the bytes in
|
|
// big-endian, so reverse them.
|
|
buf := hash.ByteArray()
|
|
blen := len(buf)
|
|
for i := 0; i < blen/2; i++ {
|
|
buf[i], buf[blen-1-i] = buf[blen-1-i], buf[i]
|
|
}
|
|
|
|
return new(big.Int).SetBytes(buf[:])
|
|
}
|