common

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2019 License: LGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package common defines a set of commonly used helper methods and data types.

Package common defines a set of commonly used helper methods and data types.

Index

Constants

View Source
const (
	// HashLength is the standardized length of a hash
	HashLength = 32

	// AddressLength is the standardized length of an address
	AddressLength = 20
)

Variables

View Source
var (
	// DataDir is the global data directory definition.
	DataDir = getDataDir()

	// ConfigDir is the global configuration directory definition.
	ConfigDir = filepath.FromSlash(fmt.Sprintf("%s/config", DataDir))

	// DbDir is the global database directory definition.
	DbDir = filepath.FromSlash(fmt.Sprintf("%s/db", DataDir))

	// PeerIdentityDir is the global p2p identity definition.
	PeerIdentityDir = filepath.FromSlash(fmt.Sprintf("%s/p2p", DataDir))
)

Functions

func CreateDirIfDoesNotExit

func CreateDirIfDoesNotExit(dir string) error

CreateDirIfDoesNotExit creates a given directory if it does not already exist.

Types

type Address

type Address [AddressLength]byte

Address represents a 20 byte, hex-encoded ECDSA public key.

func NewAddress

func NewAddress(b []byte) *Address

NewAddress formats a given byte array to an address.

func (*Address) Bytes

func (address *Address) Bytes() []byte

Bytes converts a given address to a byte array.

type Hash

type Hash [HashLength]byte

Hash represents the 32 byte output of sha3().

func NewHash

func NewHash(b []byte) Hash

NewHash converts a given hash, b, to a 32-byte mem-prefix-compliant hash.

func (Hash) Bytes

func (hash Hash) Bytes() []byte

Bytes converts a given hash to a byte array.

func (Hash) IsNil

func (hash Hash) IsNil() bool

IsNil checks if a given hash is nil.

Jump to

Keyboard shortcuts

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