polis-util
v2.0.3
Published
Utility functions for Polis hashes and targets
Downloads
4
Maintainers
Readme
polis-util
Utility functions for Polis hashes and targets
Usage
npm install polis-util
Methods
toHash(hex)
Takes a hex string that contains a Polis hash as input, and returns a Polis-protocol-friendly little-endian Buffer. Throws an error if the hex string is not of length 64 (representing a 256-bit hash).
compressTarget(target)
Converts the difficulty target target
to its compact representation (used in the "bits" field in block headers). target
should be a Buffer
(little-endian, the zeroes should be at the end). Returns a number
.
expandTarget(bits)
Converts the compressed target integer bits
to its target hash representation. Returns a Buffer
.