interfaces

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: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	FieldUint8   = 0x01
	FieldUint16  = 0x02
	FieldUint32  = 0x03
	FieldUint64  = 0x04
	FieldUint168 = 0x05
	FieldUint256 = 0x06
	FieldInt     = 0x07
	FieldInt32   = 0x08
	FieldIn64    = 0x09
	FieldBytes   = 0x0a
	FieldString  = 0x0b
	FieldBool    = 0x0c

	DefaultMaxDataSize = 1024 * 1024
)

Variables

This section is empty.

Functions

func BytesToUint64

func BytesToUint64(b []byte) uint64

func BytesToUint64List

func BytesToUint64List(b []byte) ([]uint64, error)

func GetIndexKey

func GetIndexKey(tableName string, index uint64, columnValue []byte) []byte

func GetRowKey

func GetRowKey(tableName string, rowID uint64) []byte

func GetTableIDKey

func GetTableIDKey(tableName string) []byte

func GetTableKey

func GetTableKey(tableName string) []byte

func Uint64ListToBytes

func Uint64ListToBytes(indexes []uint64) ([]byte, error)

func Uint64ToBytes

func Uint64ToBytes(value uint64) []byte

Types

type Arbitrators

type Arbitrators interface {
	NewBlocksListener

	StartUp() error
	ForceChange() error

	GetArbitrators() [][]byte
	GetCandidates() [][]byte
	GetNextArbitrators() [][]byte
	GetNextCandidates() [][]byte

	GetArbitratorsProgramHashes() []*common.Uint168
	GetCandidatesProgramHashes() []*common.Uint168

	GetOnDutyArbitrator() []byte
	GetNextOnDutyArbitrator(offset uint32) []byte

	HasArbitersMajorityCount(num uint32) bool
	HasArbitersMinorityCount(num uint32) bool

	RegisterListener(listener ArbitratorsListener)
	UnregisterListener(listener ArbitratorsListener)
}

type ArbitratorsListener

type ArbitratorsListener interface {
	OnNewElection(arbiters [][]byte)
}

type DBTable

type DBTable struct {
	// name of table
	Name string

	// primary key range from 1 to len(table.Fields)
	// if give other value, will use default rowID as primary key only
	PrimaryKey uint64

	// database index range from 1 to len(table.Fields)
	// if give values not in scope, the database index will not be effective
	Indexes []uint64

	// field name of table
	Fields []string
}

todo change fields to map[string]FieldType, change indexes to ma[uint64]struct{}

func (*DBTable) Column

func (d *DBTable) Column(fieldName string) uint64

column range from 1 to len(table.Fields), if a field name not found in table will return 0

func (*DBTable) Data

func (d *DBTable) Data(fields []*Field) ([]byte, error)

func (*DBTable) Deserialize

func (d *DBTable) Deserialize(r io.Reader) error

func (*DBTable) GetFields

func (d *DBTable) GetFields(data []byte) ([]*Field, error)

func (*DBTable) Serialize

func (d *DBTable) Serialize(w io.Writer) error

type DirectPeers

type DirectPeers struct {
	PublicKey []byte
	Address   string
	Sequence  uint32
}

type Field

type Field struct {
	Name  string
	Value interface{}
}

func (*Field) Data

func (f *Field) Data() []byte

type HeightVersions

type HeightVersions interface {
	GetDefaultTxVersion(blockHeight uint32) byte
	GetDefaultBlockVersion(blockHeight uint32) uint32

	CheckOutputPayload(blockHeight uint32, tx *types.Transaction, output *types.Output) error
	CheckOutputProgramHash(blockHeight uint32, tx *types.Transaction, programHash common.Uint168) error
	CheckCoinbaseMinerReward(blockHeight uint32, tx *types.Transaction, totalReward common.Fixed64) error
	CheckCoinbaseArbitratorsReward(blockHeight uint32, coinbase *types.Transaction, rewardInCoinbase common.Fixed64) error
	CheckVoteProducerOutputs(blockHeight uint32, tx *types.Transaction, outputs []*types.Output,
		references map[*types.Input]*types.Output, producers [][]byte) error
	CheckTxHasNoPrograms(blockHeight uint32, tx *types.Transaction) error

	GetProducersDesc(block *types.Block) ([][]byte, error)
	AddBlock(block *types.Block) (bool, bool, error)
	AddDposBlock(block *types.DposBlock) (bool, bool, error)
	AssignCoinbaseTxRewards(block *types.Block, totalReward common.Fixed64) error
	CheckConfirmedBlockOnFork(block *types.Block) error
	GetNextOnDutyArbitrator(blockHeight, dutyChangedCount, offset uint32) []byte
}

type IArbitratorsRecord

type IArbitratorsRecord interface {
	GetArbitrators(a Arbitrators) error
	SaveDposDutyChangedCount(count uint32)
	SaveCurrentArbitrators(a Arbitrators)
	SaveNextArbitrators(a Arbitrators)

	GetDirectPeers() ([]*DirectPeers, error)
	SaveDirectPeers(peers []*DirectPeers)
}

type IDBBasic

type IDBBasic interface {
	InitConnection(connParams ...interface{}) error
	Disconnect() error
}

type IDBOperator

type IDBOperator interface {
	IDBBasic

	Create(table *DBTable) error
	Insert(table *DBTable, fields []*Field) (uint64, error)
	Select(table *DBTable, inputFields []*Field) ([][]*Field, error)
	Update(table *DBTable, inputFields []*Field, updateFields []*Field) ([]uint64, error)

	SelectID(table *DBTable, inputFields []*Field) ([]uint64, error)
}

type IDposStore

type IDposStore interface {
	IDBOperator
	IEventRecord
	IArbitratorsRecord
}

IDposStore provides func for dpos

type IEventRecord

type IEventRecord interface {
	AddProposalEvent(event interface{}) error
	UpdateProposalEvent(event interface{}) error
	AddVoteEvent(event interface{}) error
	AddViewEvent(event interface{}) error
	AddConsensusEvent(event interface{}) error
	UpdateConsensusEvent(event interface{}) error
}

type NewBlocksListener

type NewBlocksListener interface {
	OnBlockReceived(b *types.Block, confirmed bool)
	OnConfirmReceived(p *types.DPosProposalVoteSlot)
}

Jump to

Keyboard shortcuts

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