cdb

package
v0.0.0-...-96daba7 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2019 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// IndexElectionResult is store prefix for election result
	IndexElectionResult = byte(0)
	// IndexPointPeriod is store prefix for period sbp info
	IndexPointPeriod = byte(1)
	// IndexPointHour is store prefix for hour sbp info
	IndexPointHour = byte(2)
	// IndexPointDay is store prefix for day sbp info
	IndexPointDay = byte(3)
)

Variables

This section is empty.

Functions

func CreateElectionResultKey

func CreateElectionResultKey(hash types.Hash) []byte

func CreateElectionResultPrefixKey

func CreateElectionResultPrefixKey() []byte

func CreatePointKey

func CreatePointKey(prefix byte, height uint64) []byte

Types

type AddrArr

type AddrArr []types.Address

AddrArr is slice of types.Address

func (AddrArr) Bytes

func (addrs AddrArr) Bytes() []byte

Bytes implement AddrArr to byte slice

func (AddrArr) SetBytes

func (addrs AddrArr) SetBytes(byt []byte) ([]types.Address, error)

SetBytes implement byte slice to types.Address slice

type ConsensusDB

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

ConsensusDB is leveldb for

func NewConsensusDB

func NewConsensusDB(db *leveldb.DB) *ConsensusDB

func (*ConsensusDB) Check

func (self *ConsensusDB) Check()

func (*ConsensusDB) DeleteElectionResultByHash

func (self *ConsensusDB) DeleteElectionResultByHash(hash types.Hash) error

func (*ConsensusDB) DeletePointByHeight

func (self *ConsensusDB) DeletePointByHeight(prefix byte, height uint64) error

func (*ConsensusDB) GetElectionResultByHash

func (self *ConsensusDB) GetElectionResultByHash(hash types.Hash) ([]types.Address, error)

func (*ConsensusDB) GetPointByHeight

func (self *ConsensusDB) GetPointByHeight(prefix byte, height uint64) (*Point, error)

func (*ConsensusDB) StoreElectionResultByHash

func (self *ConsensusDB) StoreElectionResultByHash(hash types.Hash, addrArr []types.Address) error

func (*ConsensusDB) StorePointByHeight

func (self *ConsensusDB) StorePointByHeight(prefix byte, height uint64, p *Point) error

type Content

type Content struct {
	ExpectedNum uint32
	FactualNum  uint32
}

func (*Content) AddNum

func (self *Content) AddNum(ExpectedNum uint32, FactualNum uint32)

func (Content) Copy

func (self Content) Copy() *Content

func (*Content) Merge

func (self *Content) Merge(c *Content)

func (*Content) Rate

func (self *Content) Rate() int32

type Point

type Point struct {
	PrevHash types.Hash
	Hash     types.Hash
	Sbps     map[types.Address]*Content

	Votes *VoteContent
}

func NewEmptyPoint

func NewEmptyPoint(proofHash types.Hash) *Point

func (*Point) IsEmpty

func (self *Point) IsEmpty() bool

func (*Point) Json

func (self *Point) Json() string

func (*Point) LeftAppend

func (self *Point) LeftAppend(p *Point) error

func (*Point) Marshal

func (self *Point) Marshal() ([]byte, error)

func (*Point) RightAppend

func (self *Point) RightAppend(p *Point) error

func (*Point) Unmarshal

func (self *Point) Unmarshal(buf []byte) error

type VoteContent

type VoteContent struct {
	Details map[string]*big.Int
	Total   *big.Int
}

Jump to

Keyboard shortcuts

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