common

package
v0.0.0-...-1414968 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 1, 2018 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const HashLength = 32

HashLength defines length of hashes (32 bytes)

Variables

This section is empty.

Functions

func CheckErr

func CheckErr(e error)

CheckErr simply checks errors and panics, as a guilty pleasure.

func EncodeECDSAKeys

func EncodeECDSAKeys(privateKey *ecdsa.PrivateKey, publicKey *ecdsa.PublicKey) ([]byte, []byte)

EncodeECDSAKeys takes in ECDSA objects for key pairs and returns encoded []byte formats

func FetchPrivateKey

func FetchPrivateKey(kpath string) *ecdsa.PrivateKey

FetchPrivateKey reads and decodes a private key from file stored on disk

func FetchPublicKey

func FetchPublicKey(kpath string) *ecdsa.PublicKey

FetchPublicKey reads and decodes a public key from file stored on disk

func FetchPublicKeyBytes

func FetchPublicKeyBytes(kpath string) ([]byte, error)

FetchPublicKeyBytes fetches ECDSA public key in []byte form

func HashBlockHeader

func HashBlockHeader(header *pb.PbftBlockHeader) []byte

HashBlockHeader returns a hash for a block header

func HashTxns

func HashTxns(txns []*pb.Transaction) []byte

HashTxns returns a hash of all the transactions using Merkle Patricia tries

func MakeDirIfNot

func MakeDirIfNot(dir string)

MakeDirIfNot handles dir creation operations

func MyPrint

func MyPrint(t int, format string, args ...interface{})

MyPrint provides customized colored output functionality

Types

type Hash

type Hash [32]byte

Hash defines a hash of 32 bytes

func BigToHash

func BigToHash(b *big.Int) Hash

BigToHash sets byte representation of b to hash. If b is larger than len(h), b will be cropped from the left.

func BytesToHash

func BytesToHash(b []byte) Hash

BytesToHash sets b to hash. If b is larger than len(h), b will be cropped from the left.

func HexToHash

func HexToHash(s string) Hash

HexToHash sets byte representation of s to hash. If b is larger than len(h), b will be cropped from the left.

func (Hash) Big

func (h Hash) Big() *big.Int

Big converts a hash to a big integer.

func (Hash) Bytes

func (h Hash) Bytes() []byte

Bytes gets the byte representation of the underlying hash.

func (Hash) Format

func (h Hash) Format(s fmt.State, c rune)

Format implements fmt.Formatter, forcing the byte slice to be formatted as is, without going through the stringer interface used for logging.

func (Hash) Generate

func (h Hash) Generate(rand *rand.Rand, size int) reflect.Value

Generate implements testing/quick.Generator.

func (Hash) Hex

func (h Hash) Hex() string

Hex converts a hash to a hex string.

func (Hash) MarshalText

func (h Hash) MarshalText() ([]byte, error)

MarshalText returns the hex representation of h.

func (*Hash) SetBytes

func (h *Hash) SetBytes(b []byte)

SetBytes sets the hash to the value of b. If b is larger than len(h), b will be cropped from the left.

func (Hash) String

func (h Hash) String() string

String implements the stringer interface and is used also by the logger when doing full logging into a file.

func (Hash) TerminalString

func (h Hash) TerminalString() string

TerminalString implements log.TerminalStringer, formatting a string for console output during logging.

func (*Hash) UnmarshalJSON

func (h *Hash) UnmarshalJSON(input []byte) error

UnmarshalJSON parses a hash in hex syntax.

func (*Hash) UnmarshalText

func (h *Hash) UnmarshalText(input []byte) error

UnmarshalText parses a hash in hex syntax.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL