Documentation ¶
Overview ¶
Copyright (c) 2020 Blockwatch Data Inc. Author: alex@blockwatch.cc
Index ¶
- Constants
- Variables
- type Hash
- func (hash Hash) CloneBytes() []byte
- func (hash Hash) IsEqual(target Hash) bool
- func (hash Hash) IsValid() bool
- func (hash Hash) MarshalBinary() ([]byte, error)
- func (hash Hash) MarshalText() ([]byte, error)
- func (hash *Hash) SetBytes(buf []byte) error
- func (hash Hash) String() string
- func (hash *Hash) UnmarshalBinary(buf []byte) error
- func (h *Hash) UnmarshalText(buf []byte) error
- type InlineFNV64a
Constants ¶
const HashSize = 32
HashSize of array used to store hashes. See Hash.
const MaxHashStringSize = HashSize * 2
MaxHashStringSize is the maximum length of a Hash hash string.
Variables ¶
var ErrHashStrSize = fmt.Errorf("max hash string length is %v bytes", MaxHashStringSize)
ErrHashStrSize describes an error that indicates the caller specified a hash string that has too many characters.
Functions ¶
This section is empty.
Types ¶
type Hash ¶
Hash is used in several of the bitcoin messages and common structures. It typically represents the double sha256 of data.
func NewHash ¶
NewHash returns a new Hash from a byte slice. An error is returned if the number of bytes passed in is not HashSize.
func NewHashFromStr ¶
NewHashFromStr creates a Hash from a hash string. The string should be the hexadecimal string of a byte-reversed hash, but any missing characters result in zero padding at the end of the Hash.
func (Hash) CloneBytes ¶
CloneBytes returns a copy of the bytes which represent the hash as a byte slice.
NOTE: It is generally cheaper to just slice the hash directly thereby reusing the same bytes rather than calling this method.
func (Hash) MarshalBinary ¶
func (Hash) MarshalText ¶
func (*Hash) SetBytes ¶
SetBytes sets the bytes which represent the hash. An error is returned if the number of bytes passed in is not HashSize.
func (*Hash) UnmarshalBinary ¶
func (*Hash) UnmarshalText ¶
Decode decodes the byte-reversed hexadecimal string encoding of a Hash to a destination.
type InlineFNV64a ¶
type InlineFNV64a uint64
InlineFNV64a is an alloc-free port of the standard library's fnv64a. See https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
func NewInlineFNV64a ¶
func NewInlineFNV64a() InlineFNV64a
NewInlineFNV64a returns a new instance of InlineFNV64a.
func (*InlineFNV64a) Sum ¶
func (s *InlineFNV64a) Sum() []byte
func (*InlineFNV64a) Sum64 ¶
func (s *InlineFNV64a) Sum64() uint64
Sum64 returns the uint64 of the current resulting hash.
func (*InlineFNV64a) Write ¶
func (s *InlineFNV64a) Write(data []byte) error
Write adds data to the running hash.
func (*InlineFNV64a) WriteByte ¶
func (s *InlineFNV64a) WriteByte(b byte) error
Write adds a single byte b to the running hash.
func (*InlineFNV64a) WriteString ¶
func (s *InlineFNV64a) WriteString(data string) error
Write adds data to the running hash.
Directories ¶
Path | Synopsis |
---|---|
Package blake256 implements BLAKE-256 and BLAKE-224 hash functions (SHA-3 candidate).
|
Package blake256 implements BLAKE-256 and BLAKE-224 hash functions (SHA-3 candidate). |
Package murmur3 implements Austin Appleby's non-cryptographic MurmurHash3.
|
Package murmur3 implements Austin Appleby's non-cryptographic MurmurHash3. |
Package xxHash32 implements the very fast xxHash hashing algorithm (32 bits version).
|
Package xxHash32 implements the very fast xxHash hashing algorithm (32 bits version). |
Package xxhash implements the 64-bit variant of xxHash (XXH64) as described at http://cyan4973.github.io/xxHash/.
|
Package xxhash implements the 64-bit variant of xxHash (XXH64) as described at http://cyan4973.github.io/xxHash/. |