store

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2019 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const BITSPERKEY = 10

used to compute the size of bloom filter bits array . too small will lead to high false positive rate.

View Source
const (
	MaxEvnetTaskNumber = 10000
)

Variables

View Source
var ConsensusEventTable = &interfaces.DBTable{
	Name:       "ConsensusEvent",
	PrimaryKey: 4,
	Indexes:    []uint64{3},
	Fields: []string{
		"StartTime",
		"EndTime",
		"Height",
		"RawData",
	},
}
View Source
var ProposalEventTable = &interfaces.DBTable{
	Name:       "ProposalEvent",
	PrimaryKey: 7,
	Indexes:    []uint64{1, 2, 6},
	Fields: []string{
		"Proposal",
		"BlockHash",
		"ReceivedTime",
		"EndTime",
		"Result",
		"ProposalHash",
		"RawData",
	},
}
View Source
var ViewEventTable = &interfaces.DBTable{
	Name:       "ViewEvent",
	PrimaryKey: 0,
	Indexes:    nil,
	Fields: []string{
		"ConsensusID",
		"OnDutyArbitrator",
		"StartTime",
		"Offset",
	},
}
View Source
var VoteEventTable = &interfaces.DBTable{
	Name:       "VoteEvent",
	PrimaryKey: 0,
	Indexes:    nil,
	Fields: []string{
		"ProposalID",
		"Signer",
		"ReceivedTime",
		"Result",
		"RawData",
	},
}

Functions

func InitArbitrators

func InitArbitrators(arConfig ArbitratorsConfig)

func NewDposStore

func NewDposStore(filePath string) (interfaces.IDposStore, error)

Types

type Arbitrators

type Arbitrators struct {
	DutyChangedCount uint32
	// contains filtered or unexported fields
}

func (*Arbitrators) ForceChange

func (a *Arbitrators) ForceChange() error

func (*Arbitrators) GetArbitrators

func (a *Arbitrators) GetArbitrators() [][]byte

func (*Arbitrators) GetArbitratorsProgramHashes

func (a *Arbitrators) GetArbitratorsProgramHashes() []*common.Uint168

func (*Arbitrators) GetCandidates

func (a *Arbitrators) GetCandidates() [][]byte

func (*Arbitrators) GetCandidatesProgramHashes

func (a *Arbitrators) GetCandidatesProgramHashes() []*common.Uint168

func (*Arbitrators) GetNextArbitrators

func (a *Arbitrators) GetNextArbitrators() [][]byte

func (*Arbitrators) GetNextCandidates

func (a *Arbitrators) GetNextCandidates() [][]byte

func (*Arbitrators) GetNextOnDutyArbitrator

func (a *Arbitrators) GetNextOnDutyArbitrator(offset uint32) []byte

func (*Arbitrators) GetOnDutyArbitrator

func (a *Arbitrators) GetOnDutyArbitrator() []byte

func (*Arbitrators) HasArbitersMajorityCount

func (a *Arbitrators) HasArbitersMajorityCount(num uint32) bool

func (*Arbitrators) HasArbitersMinorityCount

func (a *Arbitrators) HasArbitersMinorityCount(num uint32) bool

func (*Arbitrators) OnBlockReceived

func (a *Arbitrators) OnBlockReceived(b *types.Block, confirmed bool)

func (*Arbitrators) OnConfirmReceived

func (a *Arbitrators) OnConfirmReceived(p *types.DPosProposalVoteSlot)

func (*Arbitrators) RegisterListener

func (a *Arbitrators) RegisterListener(listener interfaces.ArbitratorsListener)

func (*Arbitrators) StartUp

func (a *Arbitrators) StartUp() error

func (*Arbitrators) UnregisterListener

func (a *Arbitrators) UnregisterListener(listener interfaces.ArbitratorsListener)

type ArbitratorsConfig

type ArbitratorsConfig struct {
	ArbitratorsCount uint32
	CandidatesCount  uint32
	MajorityCount    uint32
	Store            interfaces.IDposStore
}

type Batch

type Batch interface {
	Put(key []byte, value []byte) error
	Delete(key []byte) error
	Commit() error
	Rollback() error
}

type DataEntryPrefix

type DataEntryPrefix byte

DataEntryPrefix

const (
	// DPOS
	DPOSDutyChangedCount   DataEntryPrefix = 0x11
	DPOSCurrentArbitrators DataEntryPrefix = 0x12
	DPOSCurrentCandidates  DataEntryPrefix = 0x13
	DPOSNextArbitrators    DataEntryPrefix = 0x14
	DPOSNextCandidates     DataEntryPrefix = 0x15
	DPOSDirectPeers        DataEntryPrefix = 0x16
)

type Database

type Database interface {
	Put(key []byte, value []byte) error
	Get(key []byte) ([]byte, error)
	Delete(key []byte) error
	NewBatch() Batch
	NewIterator(prefix []byte) blockchain.IIterator
	Close() error
}

type DposStore

type DposStore struct {
	Database
	// contains filtered or unexported fields
}

func (*DposStore) AddConsensusEvent

func (s *DposStore) AddConsensusEvent(event interface{}) error

func (*DposStore) AddProposalEvent

func (s *DposStore) AddProposalEvent(event interface{}) error

func (*DposStore) AddViewEvent

func (s *DposStore) AddViewEvent(event interface{}) error

func (*DposStore) AddVoteEvent

func (s *DposStore) AddVoteEvent(event interface{}) error

func (*DposStore) Create

func (s *DposStore) Create(table *interfaces.DBTable) error

func (*DposStore) Disconnect

func (s *DposStore) Disconnect() error

func (*DposStore) GetArbitrators

func (s *DposStore) GetArbitrators(a interfaces.Arbitrators) error

func (*DposStore) GetDirectPeers

func (s *DposStore) GetDirectPeers() ([]*interfaces.DirectPeers, error)

func (*DposStore) InitConnection

func (s *DposStore) InitConnection(connParams ...interface{}) error

func (*DposStore) Insert

func (s *DposStore) Insert(table *interfaces.DBTable, fields []*interfaces.Field) (uint64, error)

func (*DposStore) SaveCurrentArbitrators

func (s *DposStore) SaveCurrentArbitrators(a interfaces.Arbitrators)

func (*DposStore) SaveDirectPeers

func (s *DposStore) SaveDirectPeers(p []*interfaces.DirectPeers)

func (*DposStore) SaveDposDutyChangedCount

func (s *DposStore) SaveDposDutyChangedCount(c uint32)

func (*DposStore) SaveNextArbitrators

func (s *DposStore) SaveNextArbitrators(a interfaces.Arbitrators)

func (*DposStore) Select

func (s *DposStore) Select(table *interfaces.DBTable, inputFields []*interfaces.Field) ([][]*interfaces.Field, error)

func (*DposStore) SelectID

func (s *DposStore) SelectID(table *interfaces.DBTable, inputFields []*interfaces.Field) ([]uint64, error)

func (*DposStore) StartRecordArbitrators

func (s *DposStore) StartRecordArbitrators()

func (*DposStore) StartRecordEvent

func (s *DposStore) StartRecordEvent() error

func (*DposStore) Update

func (s *DposStore) Update(table *interfaces.DBTable, inputFields []*interfaces.Field, updateFields []*interfaces.Field) ([]uint64, error)

func (*DposStore) UpdateConsensusEvent

func (s *DposStore) UpdateConsensusEvent(event interface{}) error

func (*DposStore) UpdateProposalEvent

func (s *DposStore) UpdateProposalEvent(event interface{}) error

type EventRecord

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

func (*EventRecord) Initialize

func (e *EventRecord) Initialize(store interfaces.IEventRecord)

func (*EventRecord) OnConsensusFinished

func (e *EventRecord) OnConsensusFinished(cons *log.ConsensusEvent)

func (*EventRecord) OnConsensusStarted

func (e *EventRecord) OnConsensusStarted(cons *log.ConsensusEvent)

func (*EventRecord) OnProposalArrived

func (e *EventRecord) OnProposalArrived(prop *log.ProposalEvent)

func (*EventRecord) OnProposalFinished

func (e *EventRecord) OnProposalFinished(prop *log.ProposalEvent)

func (*EventRecord) OnViewStarted

func (e *EventRecord) OnViewStarted(view *log.ViewEvent)

func (*EventRecord) OnVoteArrived

func (e *EventRecord) OnVoteArrived(vote *log.VoteEvent)

type LevelDB

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

func NewLevelDB

func NewLevelDB(file string) (*LevelDB, error)

func (*LevelDB) Close

func (l *LevelDB) Close() error

func (*LevelDB) Delete

func (l *LevelDB) Delete(key []byte) error

func (*LevelDB) Get

func (l *LevelDB) Get(key []byte) ([]byte, error)

func (*LevelDB) NewBatch

func (l *LevelDB) NewBatch() Batch

func (*LevelDB) NewIterator

func (l *LevelDB) NewIterator(prefix []byte) blockchain.IIterator

func (*LevelDB) Put

func (l *LevelDB) Put(key []byte, value []byte) error

Jump to

Keyboard shortcuts

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