utils

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyStringMap added in v0.4.0

func CopyStringMap(src map[string]string) (dst map[string]string)

CopyStringMap copy the src map's key and value, and return the dst map.

func CopyStringSet added in v0.4.0

func CopyStringSet(src map[string]struct{}) (dst map[string]struct{})

CopyStringSet copy the src map's key, and return the dst map.

func DeserializeStringMap added in v0.4.0

func DeserializeStringMap(r io.Reader) (smap map[string]string, err error)

func DeserializeStringSet added in v0.4.0

func DeserializeStringSet(r io.Reader) (vmap map[string]struct{}, err error)

func FileExisted

func FileExisted(filename string) bool

func GetConfirmedPassword

func GetConfirmedPassword() ([]byte, error)

GetConfirmedPassword gets double confirmed password from user input

func GetPassword

func GetPassword() ([]byte, error)

GetPassword gets password from user input

func SerializeStringMap added in v0.4.0

func SerializeStringMap(w io.Writer, smap map[string]string) (err error)

func SerializeStringSet added in v0.4.0

func SerializeStringSet(w io.Writer, vmap map[string]struct{}) (err error)

func StartPProf

func StartPProf(port uint32)

open ela pprof ,must run with goroutine

Types

type HeightChanges added in v0.4.0

type HeightChanges struct {
	// contains filtered or unexported fields
}

HeightChanges holds all changes on a particular height.

type History added in v0.4.0

type History struct {
	// contains filtered or unexported fields
}

History is a helper to log all producers and votes changes for state, so we can handle block rollback by tracing the change history, no need to loop though all transactions since the beginning of DPOS consensus.

func NewHistory added in v0.4.0

func NewHistory(cap int) *History

newHistory creates a new history instance.

func (*History) Append added in v0.4.0

func (h *History) Append(height uint32, execute func(), rollback func())

Append add a change and it's rollback into history.

func (*History) Changes added in v0.4.0

func (h *History) Changes() []HeightChanges

Changes holds the changes by the height where the changes happens.

func (*History) Commit added in v0.4.0

func (h *History) Commit(height uint32)

Commit saves the pending changes into state.

func (*History) Height added in v0.4.0

func (h *History) Height() uint32

Height returns the best height the history knows.

func (*History) RollbackTo added in v0.4.0

func (h *History) RollbackTo(height uint32) error

RollbackTo restores state to height, and remove all histories after height. If no enough histories to rollback return error.

func (*History) SeekTo added in v0.4.0

func (h *History) SeekTo(height uint32) error

SeekTo changes state to a historical height in range of history capacity.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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