Documentation
¶
Index ¶
- func EncodeToBytes(i uint64) []byte
- func GetDifficulty(p float64) uint
- func GetMask(l uint, c uint) *big.Int
- func GetMaxNonce(l int) *big.Int
- func GetNthBit(b byte, bit uint64) bool
- func GetProbability(l uint) float64
- func GetSimpleMask(l uint) *big.Int
- func Rnd(t *testing.T, l uint) []byte
- func Rnd1(l uint) []byte
- func String(b bitarray.BitArray, size uint64) (string, error)
- func Uint64Value(b bitarray.BitArray, length uint64) (uint64, error)
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncodeToBytes ¶
Get big-endian bytes encoding of i Result is 1 to 8 bytes long. 0x0 bytes is returned for 0
func GetMask ¶
Create an l bytes long bit mask with the c MSB bits set to 0 and the other bits set to 1 c*8 must be <= l
func GetMaxNonce ¶
Returns the max nonce that is l bits long. e.g. for l=256, nonce should be 2^256-1
func GetNthBit ¶
Get the bool value of the nth bit of a value of a byte bit is defined from right to left so the LSB bit is at 0 and the MSB it is at 7. e.g. byte is bits at indexes [7|6|5|4|3|2|1|0] and 0x1 is 00000001, 0x2 is 00000010
func GetProbability ¶
Get the prob (0...1) of a difficulty param l p := 1 / 2^l
func GetSimpleMask ¶
Returns an int representing l bits set to 1
Types ¶
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer implements buffering for an io.Writer object. If an error occurs writing to a Writer, no more data will be accepted and all subsequent writes, and Flush, will return the error. After all data has been written, the client should call the Flush method to guarantee all data has been forwarded to the underlying io.Writer.
func NewWriterSize ¶
NewWriterSize returns a new Writer whose buffer has at least the specified size. If the argument io.Writer is already a Writer with large enough size, it returns the underlying Writer.
func (*Writer) Buffered ¶
Buffered returns the number of bytes that have been written into the current buffer.
func (*Writer) Reset ¶
Reset discards any unflushed buffered data, clears any error, and resets b to write its output to w.