common

package
v2.10.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2021 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Origin    = 0
	PreInit   = 1
	PostInit  = 2
	PreStart  = 3
	PostStart = 4
	PreStop   = 5
	PostStop  = 6
)

BlockType types.

View Source
const (
	DwlDone = "DownloaderDoneEvent"
)

Variables

View Source
var EmptyBalance = Balance(0)
View Source
var EmptyHash = Hash("")
View Source
var EmptyHashHeight = HashHeight{
	Hash:   EmptyHash,
	Height: EmptyHeight,
}
View Source
var EmptyHeight = Height(0)
View Source
var FirstHeight = Height(1)

Functions

This section is empty.

Types

type AccountHashH

type AccountHashH struct {
	HashHeight
	Addr Address
}

func NewAccountHashH

func NewAccountHashH(address Address, hash Hash, height Height) *AccountHashH

type AccountStateBlock

type AccountStateBlock struct {
	Tblock
	Amount         Balance
	ModifiedAmount Balance
	BlockType      BlockType // 1: send  2:received
	From           Address
	To             Address
	Source         *HashHeight
}

func NewAccountBlock

func NewAccountBlock(
	height Height,
	hash Hash,
	prevHash Hash,
	signer Address,
	timestamp time.Time,

	amount Balance,
	modifiedAmount Balance,
	blockType BlockType,
	from Address,
	to Address,
	source *HashHeight,
) *AccountStateBlock

func NewAccountBlockEmpty

func NewAccountBlockEmpty() *AccountStateBlock

func NewAccountBlockFrom

func NewAccountBlockFrom(
	accountBlock *AccountStateBlock,
	signer Address,
	timestamp time.Time,

	modifiedAmount Balance,

	blockType BlockType,
	from *Address,
	to *Address,
	source *HashHeight,
) *AccountStateBlock

type Address

type Address string

func HexToAddress

func HexToAddress(hexStr string) Address

func (Address) Bytes

func (addr Address) Bytes() []byte

func (Address) String

func (addr Address) String() string

type Balance

type Balance uint64

func (Balance) String

func (balance Balance) String() string

type Block

type Block interface {
	Height() Height
	Hash() Hash
	PrevHash() Hash
	Signer() Address
	Timestamp() time.Time
}

type BlockType

type BlockType uint8

BlockType is the type of Tx described by int.

const (
	GENESIS BlockType = iota
	SEND
	RECEIVED
)

BlockType types.

func (BlockType) String

func (tp BlockType) String() string

type CondTimer

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

func NewCondTimer

func NewCondTimer() *CondTimer

func (*CondTimer) Broadcast

func (self *CondTimer) Broadcast()

func (*CondTimer) Signal

func (self *CondTimer) Signal()

func (*CondTimer) Start

func (self *CondTimer) Start(t time.Duration)

func (*CondTimer) Stop

func (self *CondTimer) Stop()

func (*CondTimer) Wait

func (self *CondTimer) Wait()

type Hash

type Hash string

func (Hash) Bytes

func (hash Hash) Bytes() []byte

func (Hash) String

func (hash Hash) String() string

type HashHeight

type HashHeight struct {
	Hash   Hash
	Height Height
}

type Height

type Height uint64

func BytesToHeight

func BytesToHeight(value []byte) Height

func (Height) Bytes

func (height Height) Bytes() []byte

func (Height) String

func (height Height) String() string

func (Height) Uint64

func (height Height) Uint64() uint64

type Lifecycle

type Lifecycle interface {
	Init()
	Start()
	Stop()
	Status() int32
}

type LifecycleStatus

type LifecycleStatus struct {
	S int32 // 0:origin 1: initing 2:inited 3:starting 4:started 5:stopping 6:stopped
}

func (*LifecycleStatus) PostInit

func (ls *LifecycleStatus) PostInit() *LifecycleStatus

func (*LifecycleStatus) PostStart

func (ls *LifecycleStatus) PostStart() *LifecycleStatus

func (*LifecycleStatus) PostStop

func (ls *LifecycleStatus) PostStop() *LifecycleStatus

func (*LifecycleStatus) PreInit

func (ls *LifecycleStatus) PreInit() *LifecycleStatus

func (*LifecycleStatus) PreStart

func (ls *LifecycleStatus) PreStart() *LifecycleStatus

func (*LifecycleStatus) PreStop

func (ls *LifecycleStatus) PreStop() *LifecycleStatus

func (*LifecycleStatus) Status

func (ls *LifecycleStatus) Status() int32

func (*LifecycleStatus) Stopped

func (ls *LifecycleStatus) Stopped() bool

type NetMsgType

type NetMsgType uint8
const (
	PeerConnected         NetMsgType = 1
	PeerClosed            NetMsgType = 2
	State                 NetMsgType = 101
	RequestAccountHash    NetMsgType = 102
	RequestSnapshotHash   NetMsgType = 103
	RequestAccountBlocks  NetMsgType = 104
	RequestSnapshotBlocks NetMsgType = 105
	AccountHashes         NetMsgType = 121
	SnapshotHashes        NetMsgType = 122
	AccountBlocks         NetMsgType = 123
	SnapshotBlocks        NetMsgType = 124
)

func (NetMsgType) String

func (tp NetMsgType) String() string

type NonBlockLock

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

func (*NonBlockLock) TryLock

func (lock *NonBlockLock) TryLock() bool

func (*NonBlockLock) UnLock

func (lock *NonBlockLock) UnLock() bool

type RWLock

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

func (*RWLock) TryRLock

func (lock *RWLock) TryRLock() bool

func (*RWLock) TryWLock

func (lock *RWLock) TryWLock() bool

func (*RWLock) UnRLock

func (lock *RWLock) UnRLock() bool

func (*RWLock) UnWLock

func (lock *RWLock) UnWLock() bool

func (*RWLock) WLock

func (lock *RWLock) WLock() bool

type Sign

type Sign string

type SnapshotBlock

type SnapshotBlock struct {
	Tblock
	Accounts []*AccountHashH
}

func NewSnapshotBlock

func NewSnapshotBlock(
	height Height,
	hash Hash,
	prevHash Hash,
	signer Address,
	timestamp time.Time,
	accounts []*AccountHashH,
) *SnapshotBlock

type SnapshotPoint

type SnapshotPoint struct {
	SnapshotHeight Height
	SnapshotHash   Hash
	AccountHeight  Height
	AccountHash    Hash
}

func (*SnapshotPoint) Equals

func (point *SnapshotPoint) Equals(peer *SnapshotPoint) bool

func (*SnapshotPoint) String

func (point *SnapshotPoint) String() string

type StoreDBType

type StoreDBType uint8
const (
	Memory  StoreDBType = 1
	LevelDB StoreDBType = 2
)

type Tblock

type Tblock struct {
	Theight    Height
	Thash      Hash
	TprevHash  Hash
	Tsigner    Address
	Ttimestamp time.Time
}

func (*Tblock) Hash

func (self *Tblock) Hash() Hash

func (*Tblock) Height

func (self *Tblock) Height() Height

func (*Tblock) PrevHash

func (self *Tblock) PrevHash() Hash

func (*Tblock) SetHash

func (self *Tblock) SetHash(hash Hash)

func (*Tblock) Signer

func (self *Tblock) Signer() Address

func (*Tblock) Timestamp

func (self *Tblock) Timestamp() time.Time

type Version

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

func (*Version) Inc

func (self *Version) Inc()

func (*Version) Val

func (self *Version) Val() uint64

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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