Version: v0.0.0-...-a4757fd Latest Latest

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

Go to latest
Published: Jul 13, 2018 License: Apache-2.0, Apache-2.0 Imports: 38 Imported by: 0




View Source
const (
	EventDataTypeNewBlock       = byte(0x01)
	EventDataTypeFork           = byte(0x02)
	EventDataTypeTx             = byte(0x03)
	EventDataTypeNewBlockHeader = byte(0x04)

	EventDataTypeSwitchToConsensus = byte(0x5)

	EventDataTypeRoundState = byte(0x11)
	EventDataTypeVote       = byte(0x12)

	EventDataTypeHookNewRound  = byte(0x21)
	EventDataTypeHookPropose   = byte(0x22)
	EventDataTypeHookPrevote   = byte(0x23)
	EventDataTypeHookPrecommit = byte(0x24)
	EventDataTypeHookCommit    = byte(0x25)
	EventDataTypeHookExecute   = byte(0x26)
View Source
const (
View Source
const (
	CoinbaseFrom   = "0000000000000000000000000000000000000000000000000000000000000000"
	CoinbaseAmount = 100
View Source
const (
	// 0x0 bytes are for the blockchain
	ResultTypeGenesis         = byte(0x01)
	ResultTypeBlockchainInfo  = byte(0x02)
	ResultTypeBlock           = byte(0x03)
	ResultTypeNonEmptyHeights = byte(0x04)

	// 0x2 bytes are for the network
	ResultTypeStatus    = byte(0x20)
	ResultTypeNetInfo   = byte(0x21)
	ResultTypeDialSeeds = byte(0x22)
	ResultTypeOrgs      = byte(0x23)

	// 0x1  bytes are for refuseList
	ResultTypeRefuseList = byte(0x10)

	// 0x4 bytes are for the consensus
	ResultTypeValidators         = byte(0x40)
	ResultTypeDumpConsensusState = byte(0x41)

	// 0x6 bytes are for txs / the application
	ResultTypeBroadcastTx       = byte(0x60)
	ResultTypeUnconfirmedTxs    = byte(0x61)
	ResultTypeBroadcastTxCommit = byte(0x62)
	ResultTypeRequestSpecialOP  = byte(0x63)

	// 0x7 bytes are for querying the application
	ResultTypeQuery        = byte(0x70)
	ResultTypeInfo         = byte(0x71)
	ResultTypeQueryNonce   = byte(0x72)
	ResultTypeQueryBalance = byte(0x73)
	ResultTypeQueryShare   = byte(0x74)
	ResultTypeQueryReceipt = byte(0x75)

	// 0x8 bytes are for events
	ResultTypeSubscribe   = byte(0x80)
	ResultTypeUnsubscribe = byte(0x81)
	ResultTypeEvent       = byte(0x82)

	// 0xa bytes for testing
	ResultTypeUnsafeSetConfig        = byte(0xa0)
	ResultTypeUnsafeStartCPUProfiler = byte(0xa1)
	ResultTypeUnsafeStopCPUProfiler  = byte(0xa2)
	ResultTypeUnsafeWriteHeapProfile = byte(0xa3)
	ResultTypeUnsafeFlushMempool     = byte(0xa4)
	ResultTypeCoreVersion            = byte(0xaf)

	// 0x9 bytes are for za_surveillance
	ResultTypeSurveillance = byte(0x90)
View Source
const MaxBlockSize = 22020096 // 21MB TODO make it configurable
View Source
const (
	PRIV_FILE_NAME = "priv_validator.json"
View Source
const (
	// angine takes query id from 0x01 to 0x2F
	QueryTxExecution = 0x01


View Source
var (
	ErrRevertFromBackup = errors.New("revert from backup,not find data")
	ErrBranchNameUsed   = errors.New("app:branch name has been used")
View Source
var (
	PeerStateKey     = "ConsensusReactor.peerState"
	PeerMempoolChKey = "MempoolReactor.peerMempoolCh"
View Source
var (
	ErrPartSetUnexpectedIndex = errors.New("Error part set unexpected index")
	ErrPartSetInvalidProof    = errors.New("Error part set invalid proof")
View Source
var (
	ErrFileNotFound       = errors.New("priv_validator.json not found")
	ErrBranchIsUsed       = errors.New("priv_validator:branch name is used")
	ErrPVRevertFromBackup = errors.New("priv_validator:revert from backup, not find data")
View Source
var (
	ErrInvalidBlockPartSignature = errors.New("Error invalid block part signature")
	ErrInvalidBlockPartHash      = errors.New("Error invalid block part hash")
View Source
var (
	ErrVoteUnexpectedStep          = errors.New("Unexpected step")
	ErrVoteInvalidValidatorIndex   = errors.New("Invalid round vote validator index")
	ErrVoteInvalidValidatorAddress = errors.New("Invalid round vote validator address")
	ErrVoteInvalidSignature        = errors.New("Invalid round vote signature")
	ErrVoteMultiSignature          = errors.New("Multi round vote signature")
	ErrVoteInvalidBlockHash        = errors.New("Invalid block hash")
	ErrVoteNilVoteSet              = errors.New("VoteSet is nil")
View Source
var GenDocKey = []byte("GenDocKey")


func AddListenerForEvent

func AddListenerForEvent(evsw EventSwitch, id, event string, cb func(data TMEventData))

func AtoHeight

func AtoHeight(heightStr string) (def.INT, error)

func Byte64Tobyte

func Byte64Tobyte(bytes64 [64]byte) (bytes []byte)

func BytesToByte32

func BytesToByte32(bytes []byte) (b32 [32]byte)

func BytesToByte64

func BytesToByte64(bytes []byte) (b64 [64]byte)

func CheckBytesZero

func CheckBytesZero(bys []byte) bool

func EventStringBond

func EventStringBond() string


func EventStringCompleteProposal

func EventStringCompleteProposal() string

func EventStringDupeout

func EventStringDupeout() string

func EventStringFork

func EventStringFork() string

func EventStringHookCommit

func EventStringHookCommit() string

func EventStringHookExecute

func EventStringHookExecute() string

func EventStringHookNewRound

func EventStringHookNewRound() string

func EventStringHookPrecommit

func EventStringHookPrecommit() string

func EventStringHookPrevote

func EventStringHookPrevote() string

func EventStringHookPropose

func EventStringHookPropose() string

func EventStringLock

func EventStringLock() string

func EventStringNewBlock

func EventStringNewBlock() string

func EventStringNewBlockHeader

func EventStringNewBlockHeader() string

func EventStringNewRound

func EventStringNewRound() string

func EventStringNewRoundStep

func EventStringNewRoundStep() string

func EventStringPolka

func EventStringPolka() string

func EventStringRebond

func EventStringRebond() string

func EventStringRelock

func EventStringRelock() string

func EventStringSwitchToConsensus

func EventStringSwitchToConsensus() string

func EventStringTimeoutPropose

func EventStringTimeoutPropose() string

func EventStringTimeoutWait

func EventStringTimeoutWait() string

func EventStringTx

func EventStringTx(tx Tx) string

func EventStringUnbond

func EventStringUnbond() string

func EventStringUnlock

func EventStringUnlock() string

func EventStringVote

func EventStringVote() string

func FireEventCompleteProposal

func FireEventCompleteProposal(fireable events.Fireable, rs EventDataRoundState)

func FireEventHookCommit

func FireEventHookCommit(fireable events.Fireable, d EventDataHookCommit)

func FireEventHookExecute

func FireEventHookExecute(fireable events.Fireable, d EventDataHookExecute)

func FireEventHookNewRound

func FireEventHookNewRound(fireable events.Fireable, d EventDataHookNewRound)

func FireEventHookPrecommit

func FireEventHookPrecommit(fireable events.Fireable, d EventDataHookPrecommit)

func FireEventHookPrevote

func FireEventHookPrevote(fireable events.Fireable, d EventDataHookPrevote)

func FireEventHookPropose

func FireEventHookPropose(fireable events.Fireable, d EventDataHookPropose)

func FireEventLock

func FireEventLock(fireable events.Fireable, rs EventDataRoundState)

func FireEventNewBlock

func FireEventNewBlock(fireable events.Fireable, block EventDataNewBlock)

func FireEventNewBlockHeader

func FireEventNewBlockHeader(fireable events.Fireable, header EventDataNewBlockHeader)

func FireEventNewRound

func FireEventNewRound(fireable events.Fireable, rs EventDataRoundState)

func FireEventNewRoundStep

func FireEventNewRoundStep(fireable events.Fireable, rs EventDataRoundState)

func FireEventPolka

func FireEventPolka(fireable events.Fireable, rs EventDataRoundState)

func FireEventRelock

func FireEventRelock(fireable events.Fireable, rs EventDataRoundState)

func FireEventSwitchToConsensus

func FireEventSwitchToConsensus(fireable events.Fireable)

func FireEventTimeoutPropose

func FireEventTimeoutPropose(fireable events.Fireable, rs EventDataRoundState)

func FireEventTimeoutWait

func FireEventTimeoutWait(fireable events.Fireable, rs EventDataRoundState)

func FireEventTx

func FireEventTx(fireable events.Fireable, tx EventDataTx)

func FireEventUnlock

func FireEventUnlock(fireable events.Fireable, rs EventDataRoundState)

func FireEventVote

func FireEventVote(fireable events.Fireable, vote EventDataVote)

func HashSignBytes

func HashSignBytes(chainID string, o Signable) []byte

HashSignBytes is a convenience method for getting the hash of the bytes of a signable

func HeightToA

func HeightToA(height def.INT) string

func IsExtendedTx

func IsExtendedTx(tx []byte) bool

func IsSuspectTx

func IsSuspectTx(tx []byte) bool

func MakeBlock

func MakeBlock(maker, coinbase []byte, height def.INT, chainID string, alltxs []Tx, commit *CommitCache,
	prevBlockID pbtypes.BlockID, valHash []byte, vset *ValidatorSet, appHash, receiptsHash []byte, partSize, nonEmptyHeight def.INT) (*BlockCache, *PartSet)

TODO: version

func MarshalData

func MarshalData(pb proto.Message) ([]byte, error)

func NanoToTime

func NanoToTime(nano def.INT) time.Time

func NewBlockMeta

func NewBlockMeta(block *BlockCache, blockParts *PartSet) *pbtypes.BlockMeta

func NewDefaultPubKey

func NewDefaultPubKey(pkeybytes []byte) crypto.PubKey

func NewDefaultSignature

func NewDefaultSignature(sigbytes []byte) crypto.Signature

func NewProposal

func NewProposal(height, round def.INT, blockPartsHeader pbtypes.PartSetHeader, polRound def.INT, polBlockID pbtypes.BlockID) *pbtypes.Proposal

polRound: -1 if no polRound.

func PbDataToPubkey

func PbDataToPubkey(pubkey *pbtypes.PubKey) crypto.PubKey

func PrivKeyByteToByte64

func PrivKeyByteToByte64(bytes []byte) (byte64 [64]byte)

func PubkeyToPbData

func PubkeyToPbData(pubkey crypto.PubKey) *pbtypes.PubKey

func RandValidator

func RandValidator(logger *zap.Logger, randPower bool, minPower def.INT) (*Validator, *PrivValidator)

func RandValidatorSet

func RandValidatorSet(logger *zap.Logger, numValidators int, votingPower def.INT) (*ValidatorSet, []*PrivValidator)

NOTE: PrivValidator are in order.

func SignBytes

func SignBytes(chainID string, o Signable) []byte

SignBytes is a convenience method for getting the bytes to sign of a Signable.

func StrToSmallStr

func StrToSmallStr(str string) (smallstr string)

func StringTo32byte

func StringTo32byte(key string) ([32]byte, error)

func StringTo64byte

func StringTo64byte(key string) ([64]byte, error)

func StringToAnybyte

func StringToAnybyte(key string) ([]byte, error)

func Substr

func Substr(str string, start int, length int) string

func UnmarshalData

func UnmarshalData(buf []byte, pb proto.Message) error

func UnwrapTx

func UnwrapTx(tx []byte) []byte

func WrapTx

func WrapTx(prefix []byte, tx []byte) []byte


type Application

type Application interface {
	GetAngineHooks() Hooks
	CheckTx([]byte) error
	Query([]byte) Result
	Info() ResultInfo
	Start() error
	Initialized() bool
	ValSetLoader() ValSetLoaderFunc                // not necessary
	SuspectValidator(pubkey []byte, reason string) // not necessary

	// extra queries
	QueryNonce(addrBytes []byte) ResultQueryNonce
	QueryBalance(addrBytes []byte) ResultQueryBalance
	QueryShare(pubkeyBytes []byte) ResultQueryShare
	QueryReceipt(txHash []byte) ResultQueryReceipt
	QueryContract(rawtx []byte) ResultQueryContract
	//QueryContractExistance(addrBytes []byte) ResultQueryContractExistance
	QueryTx(txHash []byte) ResultQueryTx

type BaseAppTool

type BaseAppTool struct {

func (*BaseAppTool) BackupLastBlockData

func (t *BaseAppTool) BackupLastBlockData(branchName string, lastBlock interface{}) error

func (*BaseAppTool) DelBackup

func (t *BaseAppTool) DelBackup(branchName string)

func (*BaseAppTool) RevertFromBackup

func (t *BaseAppTool) RevertFromBackup(branchName string) error

type BaseApplication

type BaseApplication struct {
	Database         db.DB
	InitializedState bool

BaseApplication defines the default save/load last block implementations You can write all on your own, but embed this will save u some breath

func (*BaseApplication) InitBaseApplication

func (ba *BaseApplication) InitBaseApplication(name string, datadir string) (err error)

InitBaseApplication must be the first thing to be called when an application embeds BaseApplication

func (*BaseApplication) Initialized

func (ba *BaseApplication) Initialized() bool

Initialized returns if a BaseApplication based app has been fully initialized

func (*BaseApplication) LoadLastBlock

func (ba *BaseApplication) LoadLastBlock(t interface{}) (res interface{}, err error)

func (*BaseApplication) SaveLastBlock

func (ba *BaseApplication) SaveLastBlock(lastBlock interface{})

func (*BaseApplication) SaveLastBlockByKey

func (ba *BaseApplication) SaveLastBlockByKey(key []byte, lastBlock interface{})

func (*BaseApplication) Stop

func (ba *BaseApplication) Stop()

Stop handles freeing resources taken by BaseApplication

func (*BaseApplication) SuspectValidator

func (ba *BaseApplication) SuspectValidator(pubkey []byte, reason string)

SuspectValidator suggest punishment when needed

func (*BaseApplication) ValSetLoader

func (ba *BaseApplication) ValSetLoader() ValSetLoaderFunc

ValSetLoader default funtion that return nil

type BlockCache

type BlockCache struct {
	// contains filtered or unexported fields

func MakeBlockCache

func MakeBlockCache(block *pbtypes.Block) *BlockCache

func (*BlockCache) CommitCache

func (b *BlockCache) CommitCache() *CommitCache

func (*BlockCache) DataCache

func (b *BlockCache) DataCache() *DataCache

func (*BlockCache) FillHeader

func (b *BlockCache) FillHeader()

func (*BlockCache) Hash

func (b *BlockCache) Hash() []byte

Computes and returns the block hash. If the block is incomplete, block hash is nil for safety.

func (*BlockCache) HashesTo

func (b *BlockCache) HashesTo(hash []byte) bool

Convenience. A nil block never hashes to anything. Nothing hashes to a nil hash.

func (*BlockCache) MakePartSet

func (b *BlockCache) MakePartSet(partSize def.INT) *PartSet

func (*BlockCache) String

func (b *BlockCache) String() string

func (*BlockCache) StringIndented

func (b *BlockCache) StringIndented(indent string) string

func (*BlockCache) StringShort

func (b *BlockCache) StringShort() string

func (*BlockCache) VSetCache

func (b *BlockCache) VSetCache() *ValidatorSet

func (*BlockCache) ValidateBasic

func (b *BlockCache) ValidateBasic(chainID string, lastBlockHeight def.INT, lastBlockID pbtypes.BlockID,
	lastBlockTime def.INT, appHash, receiptsHash []byte, nonEmptyHeight def.INT) error

Basic validation that doesn't involve state data.

type Bytes

type Bytes []byte

func (*Bytes) Bytes

func (b *Bytes) Bytes() []byte

func (*Bytes) MarshalJSON

func (b *Bytes) MarshalJSON() ([]byte, error)

func (*Bytes) String

func (b *Bytes) String() string

func (*Bytes) UnmarshalJSON

func (b *Bytes) UnmarshalJSON(data []byte) error

type CommApplication

type CommApplication struct {
	Listener net.Listener
	// contains filtered or unexported fields

CommApplication defines an app with basic net io ability

func (*CommApplication) Listen

func (ca *CommApplication) Listen(addr string) (net.Listener, error)

func (*CommApplication) Lock

func (ca *CommApplication) Lock()

func (*CommApplication) Stop

func (ca *CommApplication) Stop()

func (*CommApplication) Unlock

func (ca *CommApplication) Unlock()

type CommitCache

type CommitCache struct {
	// contains filtered or unexported fields

NOTE: Commit is empty for height 1, but never nil.

func NewCommitCache

func NewCommitCache(c *pbtypes.Commit) *CommitCache

func (*CommitCache) BitArray

func (commit *CommitCache) BitArray() *BitArray

func (*CommitCache) CSize

func (commit *CommitCache) CSize() int

func (*CommitCache) FirstPrecommit

func (commit *CommitCache) FirstPrecommit() *pbtypes.Vote

func (*CommitCache) GetByIndex

func (commit *CommitCache) GetByIndex(index int) *pbtypes.Vote

func (*CommitCache) Hash

func (commit *CommitCache) Hash() []byte

func (*CommitCache) Height

func (commit *CommitCache) Height() def.INT

func (*CommitCache) IsCommit

func (commit *CommitCache) IsCommit() bool

func (*CommitCache) Round

func (commit *CommitCache) Round() def.INT

func (*CommitCache) StringIndented

func (commit *CommitCache) StringIndented(indent string) string

func (*CommitCache) Type

func (commit *CommitCache) Type() pbtypes.VoteType

func (*CommitCache) ValidateBasic

func (commit *CommitCache) ValidateBasic() error

type CommitResult

type CommitResult struct {
	AppHash      []byte
	ReceiptsHash []byte

type DataCache

type DataCache struct {
	// contains filtered or unexported fields

func (*DataCache) Hash

func (data *DataCache) Hash() []byte

func (*DataCache) StringIndented

func (data *DataCache) StringIndented(indent string) string

type DefaultSigner

type DefaultSigner struct {
	// contains filtered or unexported fields

Implements Signer

func NewDefaultSigner

func NewDefaultSigner(priv crypto.PrivKey) *DefaultSigner

func (*DefaultSigner) Sign

func (ds *DefaultSigner) Sign(msg []byte) crypto.Signature

Implements Signer

type ErrVoteConflictingVotes

type ErrVoteConflictingVotes struct {
	VoteA *pbtypes.Vote
	VoteB *pbtypes.Vote

func (*ErrVoteConflictingVotes) Error

func (err *ErrVoteConflictingVotes) Error() string

type ErrWrongAppHash

type ErrWrongAppHash error

func NewErrWrongAppHash

func NewErrWrongAppHash(chainID string, expected, got []byte) ErrWrongAppHash

type ErrWrongBasic

type ErrWrongBasic error

func NewErrWrongBasic

func NewErrWrongBasic(err error) ErrWrongBasic

type ErrWrongBlockID

type ErrWrongBlockID error

func NewErrWrongBlockID

func NewErrWrongBlockID(chainID string, expected, got pbtypes.BlockID) ErrWrongBlockID

type ErrWrongChainID

type ErrWrongChainID error

func NewErrWrongChainID

func NewErrWrongChainID(expected, got string) ErrWrongChainID

type ErrWrongDataHash

type ErrWrongDataHash error

func NewErrWrongDataHash

func NewErrWrongDataHash(chainID string, expected, got []byte) ErrWrongDataHash

type ErrWrongHeight

type ErrWrongHeight error

func NewErrWrongHeight

func NewErrWrongHeight(chainID string, expected, got int) ErrWrongHeight

type ErrWrongLastCommitHash

type ErrWrongLastCommitHash error

func NewErrWrongLastCommitHash

func NewErrWrongLastCommitHash(chainID string, expected, got []byte) ErrWrongLastCommitHash

type ErrWrongNonEmptyHeight

type ErrWrongNonEmptyHeight error

func NewErrWrongNonEmptyHeight

func NewErrWrongNonEmptyHeight(chainID string, expected, got int) ErrWrongNonEmptyHeight

type ErrWrongNumTxs

type ErrWrongNumTxs error

func NewErrWrongNumTxs

func NewErrWrongNumTxs(chainID string, expected, got int) ErrWrongNumTxs

type ErrWrongReceiptsHash

type ErrWrongReceiptsHash error

func NewErrWrongReceiptsHash

func NewErrWrongReceiptsHash(chainID string, expected, got []byte) ErrWrongReceiptsHash

type EventCache

type EventCache interface {

func NewEventCache

func NewEventCache(evsw EventSwitch) EventCache

type EventDataHookCommit

type EventDataHookCommit struct {
	Height def.INT
	Round  def.INT
	Block  *BlockCache
	ResCh  chan CommitResult

func NewEventDataHookCommit

func NewEventDataHookCommit(height, round def.INT, block *BlockCache) EventDataHookCommit

func (EventDataHookCommit) AssertIsTMEventData

func (_ EventDataHookCommit) AssertIsTMEventData()

type EventDataHookExecute

type EventDataHookExecute struct {
	Height def.INT
	Round  def.INT
	Block  *BlockCache
	ResCh  chan ExecuteResult

func NewEventDataHookExecute

func NewEventDataHookExecute(height, round def.INT, block *BlockCache) EventDataHookExecute

func (EventDataHookExecute) AssertIsTMEventData

func (_ EventDataHookExecute) AssertIsTMEventData()

type EventDataHookNewRound

type EventDataHookNewRound struct {
	Height def.INT
	Round  def.INT
	ResCh  chan NewRoundResult

func NewEventDataHookNewRound

func NewEventDataHookNewRound(height, round def.INT) EventDataHookNewRound

func (EventDataHookNewRound) AssertIsTMEventData

func (_ EventDataHookNewRound) AssertIsTMEventData()

type EventDataHookPrecommit

type EventDataHookPrecommit struct {
	Height def.INT
	Round  def.INT
	Block  *BlockCache

func (EventDataHookPrecommit) AssertIsTMEventData

func (_ EventDataHookPrecommit) AssertIsTMEventData()

type EventDataHookPrevote

type EventDataHookPrevote struct {
	Height def.INT
	Round  def.INT
	Block  *BlockCache

func (EventDataHookPrevote) AssertIsTMEventData

func (_ EventDataHookPrevote) AssertIsTMEventData()

type EventDataHookPropose

type EventDataHookPropose struct {
	Height def.INT
	Round  def.INT
	Block  *BlockCache

func (EventDataHookPropose) AssertIsTMEventData

func (_ EventDataHookPropose) AssertIsTMEventData()

type EventDataNewBlock

type EventDataNewBlock struct {
	Block *BlockCache `json:"block"`

func (EventDataNewBlock) AssertIsTMEventData

func (_ EventDataNewBlock) AssertIsTMEventData()

type EventDataNewBlockHeader

type EventDataNewBlockHeader struct {
	Header *pbtypes.Header `json:"header"`

light weight event for benchmarking

func (EventDataNewBlockHeader) AssertIsTMEventData

func (_ EventDataNewBlockHeader) AssertIsTMEventData()

type EventDataRoundState

type EventDataRoundState struct {

NOTE: This goes into the replay WAL

func (EventDataRoundState) AssertIsTMEventData

func (_ EventDataRoundState) AssertIsTMEventData()

func (EventDataRoundState) MarshalJSON

func (ed EventDataRoundState) MarshalJSON() ([]byte, error)

func (*EventDataRoundState) UnmarshalJSON

func (ed *EventDataRoundState) UnmarshalJSON(data []byte) error

type EventDataRoundStateJson

type EventDataRoundStateJson struct {
	Height def.INT `json:"height"`
	Round  def.INT `json:"round"`
	Step   string  `json:"step"`

	// private, not exposed to websockets
	RoundState interface{} `json:"-"`

type EventDataSwitchToConsensus

type EventDataSwitchToConsensus struct {
	State interface{}

func (EventDataSwitchToConsensus) AssertIsTMEventData

func (_ EventDataSwitchToConsensus) AssertIsTMEventData()

type EventDataTx

type EventDataTx struct {
	Tx    Tx               `json:"tx"`
	Data  []byte           `json:"data"`
	Log   string           `json:"log"`
	Code  pbtypes.CodeType `json:"code"`
	Error string           `json:"error"` // this is redundant information for now

All txs fire EventDataTx

func (EventDataTx) AssertIsTMEventData

func (_ EventDataTx) AssertIsTMEventData()

type EventDataVote

type EventDataVote struct {
	Vote *pbtypes.Vote

func (EventDataVote) AssertIsTMEventData

func (_ EventDataVote) AssertIsTMEventData()

type EventSwitch

type EventSwitch interface {

func NewEventSwitch

func NewEventSwitch(logger *zap.Logger) EventSwitch

type Eventable

type Eventable interface {

type ExecuteInvalidTx

type ExecuteInvalidTx struct {
	Bytes Tx
	Error error

type ExecuteResult

type ExecuteResult struct {
	ValidTxs   Txs
	InvalidTxs []ExecuteInvalidTx
	Error      error

type Fireable

type Fireable interface {

type GenesisDoc

type GenesisDoc struct {
	GenesisTime Time               `json:"genesis_time"`
	ChainID     string             `json:"chain_id"`
	Validators  []GenesisValidator `json:"validators"`
	AppHash     Bytes              `json:"app_hash"`
	Plugins     string             `json:"plugins"`

	InitToken []struct {
		Address string `json:"address"`
		Amount  string `json:"amount"`
		Extra   string `json:"extra"`
	} `json:"init_token"`

	InitShare []struct {
		Pubkey string `json:"pubkey"`
		Amount string `json:"amount"`
		Extra  string `json:"extra"`
	} `json:"init_share"`

func GenesisDocFromJSON

func GenesisDocFromJSON(jsonBlob []byte) (genState *GenesisDoc)

func (*GenesisDoc) JSONBytes

func (genDoc *GenesisDoc) JSONBytes() ([]byte, error)

func (*GenesisDoc) SaveAs

func (genDoc *GenesisDoc) SaveAs(file string) error

Utility method for saving GenensisDoc as JSON file.

type GenesisValidator

type GenesisValidator struct {
	PubKey crypto.StPubKey `json:"pub_key"`
	Amount int64           `json:"amount"`
	Name   string          `json:"name"`
	IsCA   bool            `json:"is_ca"`

func (*GenesisValidator) UnmarshalJSON

func (gv *GenesisValidator) UnmarshalJSON(data []byte) error

type GenesisValidatorJson

type GenesisValidatorJson struct {
	PubKey [32]byte `json:"pub_key"`
	Amount int64    `json:"amount"`
	Name   string   `json:"name"`
	IsCA   bool     `json:"is_ca"`

func (*GenesisValidatorJson) UnmarshalJSON

func (gv *GenesisValidatorJson) UnmarshalJSON(b []byte) error

type Hook

type Hook struct {
	// contains filtered or unexported fields

func NewHook

func NewHook(cb HookCallbackFunc) *Hook

func (*Hook) Async

func (h *Hook) Async(height, round def.INT, block *BlockCache, cb func(interface{}), onError func(error))

func (*Hook) Error

func (h *Hook) Error() error

func (*Hook) Result

func (h *Hook) Result() interface{}

func (*Hook) Sync

func (h *Hook) Sync(height, round def.INT, block *BlockCache) (interface{}, error)

type HookCallbackFunc

type HookCallbackFunc func(height, round def.INT, block *BlockCache) (interface{}, error)

type Hooker

type Hooker interface {
	Sync(def.INT, def.INT, *BlockCache) (interface{}, error)
	Async(def.INT, def.INT, *BlockCache)
	Result() interface{}

type Hooks

type Hooks struct {
	OnNewRound  *Hook
	OnPropose   *Hook
	OnPrevote   *Hook
	OnPrecommit *Hook
	OnCommit    *Hook
	OnExecute   *Hook

type HypoBadVoteEvidence

type HypoBadVoteEvidence struct {
	PubKey        string
	VoteType      pbtypes.VoteType
	Height        def.INT
	Round         def.INT
	Got           *pbtypes.Vote
	Expected      *pbtypes.Vote
	ValidatorSize int

type HypoDisconnectEvidence

type HypoDisconnectEvidence struct {
	PubKey string

type HypoProposalTimeoutEvidence

type HypoProposalTimeoutEvidence struct {
	Proposal      *pbtypes.Proposal
	BlockPartsBA  *common.BitArray
	Height        def.INT
	Round         def.INT
	ValidatorSize int

type Hypocrite

type Hypocrite struct {
	PubKey   string
	Reason   byte
	Evidence interface{}
	Time     time.Time

func NewHypocrite

func NewHypocrite(pk string, reason byte, evidence interface{}) *Hypocrite

func (*Hypocrite) MarshalJSON

func (h *Hypocrite) MarshalJSON() ([]byte, error)

func (*Hypocrite) UnmarshalJSON

func (h *Hypocrite) UnmarshalJSON(bs []byte) error

type Hypocrites

type Hypocrites []*Hypocrite

func NewHypocrites

func NewHypocrites() Hypocrites

type IBadVoteCollector

type IBadVoteCollector interface {
	ReportBadVote(crypto.PubKey, interface{})

type IBlockTick

type IBlockTick interface {

type IDisconnectCollector

type IDisconnectCollector interface {
	ReportDisconnect(crypto.PubKey, interface{})

type IMempool

type IMempool interface {
	Update(height def.INT, txs []Tx)

type NewRoundResult

type NewRoundResult struct {

type NodeTransaction

type NodeTransaction struct {
	From      []byte `json:"from"`
	To        []byte `json:"to"`
	Signatrue []byte `json:"signatrue"`
	Amount    uint64 `json:"amount"`

func NewNodeTransaction

func NewNodeTransaction(from, to []byte, amount uint64) *NodeTransaction

func (*NodeTransaction) FillSign

func (nx *NodeTransaction) FillSign(sig []byte)

func (*NodeTransaction) FromBytes

func (nx *NodeTransaction) FromBytes(data []byte) error

func (*NodeTransaction) ToBytes

func (nx *NodeTransaction) ToBytes() []byte

type PartCache

type PartCache struct {
	// contains filtered or unexported fields

func NewPartCache

func NewPartCache(p *pbtypes.Part) *PartCache

func (*PartCache) CString

func (part *PartCache) CString() string

func (*PartCache) Hash

func (part *PartCache) Hash() []byte

func (*PartCache) StringIndented

func (part *PartCache) StringIndented(indent string) string

type PartSet

type PartSet struct {
	// contains filtered or unexported fields

func NewPartSetFromData

func NewPartSetFromData(data []byte, partSize def.INT) *PartSet

Returns an immutable, full PartSet from the data bytes. The data bytes are split into "partSize" chunks, and merkle tree computed.

func NewPartSetFromHeader

func NewPartSetFromHeader(header *pbtypes.PartSetHeader) *PartSet

Returns an empty PartSet ready to be populated.

func (*PartSet) AddPart

func (ps *PartSet) AddPart(part *pbtypes.Part, verify bool) (bool, error)

func (*PartSet) AssembleToBlock

func (ps *PartSet) AssembleToBlock(partSize def.INT) *BlockCache

func (*PartSet) BitArray

func (ps *PartSet) BitArray() *BitArray

func (*PartSet) Count

func (ps *PartSet) Count() def.INT

func (*PartSet) GetPart

func (ps *PartSet) GetPart(index int) *pbtypes.Part

func (*PartSet) HasHeader

func (ps *PartSet) HasHeader(header *pbtypes.PartSetHeader) bool

func (*PartSet) Hash

func (ps *PartSet) Hash() []byte

func (*PartSet) HashesTo

func (ps *PartSet) HashesTo(hash []byte) bool

func (*PartSet) Header

func (ps *PartSet) Header() *pbtypes.PartSetHeader

func (*PartSet) IsComplete

func (ps *PartSet) IsComplete() bool

func (*PartSet) StringShort

func (ps *PartSet) StringShort() string

func (*PartSet) Total

func (ps *PartSet) Total() def.INT

type Peer

type Peer struct {
	p2p.NodeInfo     `json:"node_info"`
	IsOutbound       bool                 `json:"is_outbound"`
	ConnectionStatus p2p.ConnectionStatus `json:"connection_status"`

type PrivValidator

type PrivValidator struct {
	Signer `json:"-"`
	// contains filtered or unexported fields

func GenPrivValidator

func GenPrivValidator(logger *zap.Logger) *PrivValidator

Generates a new validator with private key.

func LoadOrGenPrivValidator

func LoadOrGenPrivValidator(logger *zap.Logger, filePath string) *PrivValidator

func LoadPrivValidator

func LoadPrivValidator(logger *zap.Logger, filePath string) *PrivValidator

func (*PrivValidator) CopyReset

func (pv *PrivValidator) CopyReset() (cp PrivValidator)

func (*PrivValidator) GetAddress

func (privVal *PrivValidator) GetAddress() []byte

func (*PrivValidator) GetCoinbase

func (privVal *PrivValidator) GetCoinbase() []byte

func (*PrivValidator) GetLastSignature

func (pv *PrivValidator) GetLastSignature() crypto.Signature

func (*PrivValidator) GetPrivKey

func (pv *PrivValidator) GetPrivKey() crypto.PrivKey

func (*PrivValidator) GetPubKey

func (pv *PrivValidator) GetPubKey() crypto.PubKey

func (*PrivValidator) MarshalJSON

func (pv *PrivValidator) MarshalJSON() ([]byte, error)

func (*PrivValidator) Reset

func (privVal *PrivValidator) Reset()

NOTE: Unsafe!

func (*PrivValidator) Save

func (privVal *PrivValidator) Save()

func (*PrivValidator) SetFile

func (privVal *PrivValidator) SetFile(filePath string)

func (*PrivValidator) SetSigner

func (privVal *PrivValidator) SetSigner(s Signer)

func (*PrivValidator) SignProposal

func (privVal *PrivValidator) SignProposal(chainID string, proposal *pbtypes.Proposal) error

func (*PrivValidator) SignVote

func (privVal *PrivValidator) SignVote(chainID string, vote *pbtypes.Vote) error

func (*PrivValidator) String

func (privVal *PrivValidator) String() string

func (*PrivValidator) UnmarshalJSON

func (pv *PrivValidator) UnmarshalJSON(data []byte) error

type PrivValidatorJSON

type PrivValidatorJSON struct {
	PubKey        crypto.StPubKey    `json:"pub_key"`
	Coinbase      Bytes              `json:"coin_base"`
	LastHeight    def.INT            `json:"last_height"`
	LastRound     def.INT            `json:"last_round"`
	LastStep      int8               `json:"last_step"`
	LastSignature crypto.StSignature `json:"last_signature"` // so we dont lose signatures
	LastSignBytes Bytes              `json:"last_signbytes"` // so we dont lose signatures

	// PrivKey should be empty if a Signer other than the default is being used.
	PrivKey crypto.StPrivKey `json:"priv_key"`

type PrivValidatorTool

type PrivValidatorTool struct {
	// contains filtered or unexported fields

func (*PrivValidatorTool) BackupData

func (pt *PrivValidatorTool) BackupData(branchName string) error

func (*PrivValidatorTool) DelBackup

func (pt *PrivValidatorTool) DelBackup(branchName string)

func (*PrivValidatorTool) Init

func (pt *PrivValidatorTool) Init(dir string) error

func (*PrivValidatorTool) RevertFromBackup

func (pt *PrivValidatorTool) RevertFromBackup(branchName string) error

func (*PrivValidatorTool) SaveNewPrivV

func (pt *PrivValidatorTool) SaveNewPrivV(toHeight def.INT) error

type PrivValidatorsByAddress

type PrivValidatorsByAddress []*PrivValidator

func (PrivValidatorsByAddress) Len

func (pvs PrivValidatorsByAddress) Len() int

func (PrivValidatorsByAddress) Less

func (pvs PrivValidatorsByAddress) Less(i, j int) bool

func (PrivValidatorsByAddress) Swap

func (pvs PrivValidatorsByAddress) Swap(i, j int)

type RPCResult

type RPCResult interface {

type Result

type Result struct {
	Code pbtypes.CodeType
	Data []byte
	Log  string // Can be non-deterministic

CONTRACT: a zero Result is OK.

func NewError

func NewError(code pbtypes.CodeType, log string) Result

func NewResult

func NewResult(code pbtypes.CodeType, data []byte, log string) Result

func NewResultOK

func NewResultOK(data []byte, log string) Result

NOTE: if data == nil and log == "", same as zero Result.

func (Result) AppendLog

func (res Result) AppendLog(log string) Result

func (Result) Error

func (res Result) Error() string

func (Result) IsErr

func (res Result) IsErr() bool

func (Result) IsOK

func (res Result) IsOK() bool

func (Result) PrependLog

func (res Result) PrependLog(log string) Result

func (Result) SetData

func (res Result) SetData(data []byte) Result

func (Result) SetLog

func (res Result) SetLog(log string) Result

func (Result) String

func (res Result) String() string

type ResultBlock

type ResultBlock struct {
	Header     *ResultHeader       `json:"header"`
	Data       *ResultData         `json:"data"`
	LastCommit *ResultCommit       `json:"last_commit"`
	VSet       *ResultValidatorSet `json:"validator_set"`

func (*ResultBlock) Adapt

func (r *ResultBlock) Adapt(m *pbtypes.Block) *ResultBlock

type ResultBlockID

type ResultBlockID struct {
	Hash        hexutil.Bytes        `json:"hash"`
	PartsHeader *ResultPartSetHeader `json:"parts_header"`

func (*ResultBlockID) Adapt

type ResultBlockInfo

type ResultBlockInfo struct {
	BlockMeta *ResultBlockMeta `json:"block_meta"`
	Block     *ResultBlock     `json:"block"`

type ResultBlockMeta

type ResultBlockMeta struct {
	Hash hexutil.Bytes `json:"hash"`
	// removed for duplication
	//Header      *ResultHeader        `json:"header,"
	PartsHeader *ResultPartSetHeader `json:"parts_header"`

ResultBlockMeta simply duplicates pbtypes.BlockMeta but change the way to marshal []byte. So we will not change the structs generated by protobuf. By default, go json encodes []byte as base64. In our response it will be a plain HEX string prefixed by 0x. Meanwhile changed json key names to lowercase for better naming convention

func (*ResultBlockMeta) Adapt

type ResultBlockRaw

type ResultBlockRaw struct {
	BlockMeta *pbtypes.BlockMeta `json:"block_meta"`
	Block     *pbtypes.Block     `json:"block"`

type ResultBlockTx

type ResultBlockTx struct {
	GasLimit  *number.BigNumber `json:"gas_limit"`
	GasPrice  *number.BigNumber `json:"gas_price"`
	Nonce     uint64            `json:"nonce"`
	Sender    hexutil.Bytes     `json:"sender"`
	Payload   interface{}       `json:"payload"`
	Signature hexutil.Bytes     `json:"signature"`
	Tx_Type   string            `json:"tx_type"`

type ResultBlockchainInfo

type ResultBlockchainInfo struct {
	LastHeight def.INT            `json:"last_height"`
	BlockMetas []*ResultBlockMeta `json:"block_metas"`

type ResultBroadcastTx

type ResultBroadcastTx struct {
	Code pbtypes.CodeType `json:"code"`
	Data hexutil.Bytes    `json:"data"`
	Log  string           `json:"log"`

type ResultBroadcastTxCommit

type ResultBroadcastTxCommit struct {
	Code pbtypes.CodeType `json:"code"`
	Data hexutil.Bytes    `json:"data"`
	Log  string           `json:"log"`

type ResultCommit

type ResultCommit struct {
	BlockID    *ResultBlockID `json:"block_id"`
	Precommits []*ResultVote  `json:"pre_commits"`

func (*ResultCommit) Adapt

func (r *ResultCommit) Adapt(m *pbtypes.Commit) *ResultCommit

type ResultContractPayload

type ResultContractPayload struct {
	Code pbtypes.CodeType `json:"code"`
	Data hexutil.Bytes    `json:"data"`
	Log  string           `json:"log"`

type ResultCoreVersion

type ResultCoreVersion struct {
	Version    string `json:"version"`
	AppName    string `json:"appname"`
	AppVersion string `json:"appversion"`
	Hash       string `json:"hash"`

type ResultData

type ResultData struct {
	//Txs   []hexutil.Bytes `json:"txs"`
	//ExTxs []hexutil.Bytes `json:"ex_txs"`
	// Return the hash of the transactions
	// Use another call to get the details
	Txs   []hexutil.Bytes `json:"txs"`
	ExTxs []hexutil.Bytes `json:"ex_txs"`

func (*ResultData) Adapt

func (r *ResultData) Adapt(m *pbtypes.Data) *ResultData

type ResultDialSeeds

type ResultDialSeeds struct {

type ResultDumpConsensusState

type ResultDumpConsensusState struct {
	RoundState      string   `json:"round_state"`
	PeerRoundStates []string `json:"peer_round_states"`

type ResultEvent

type ResultEvent struct {
	Name string      `json:"name"`
	Data TMEventData `json:"data"`

type ResultGenesis

type ResultGenesis struct {
	Genesis *GenesisDoc `json:"genesis"`

type ResultHeader

type ResultHeader struct {
	ChainID            string         `json:"chain_id"`
	Height             int64          `json:"height"`
	Time               int64          `json:"time"`
	NumTxs             int64          `json:"num_txs"`
	Maker              hexutil.Bytes  `json:"maker"`
	LastBlockID        *ResultBlockID `json:"last_block_id"`
	LastCommitHash     hexutil.Bytes  `json:"last_commit_hash"`
	DataHash           hexutil.Bytes  `json:"data_hash"`
	ValidatorsHash     hexutil.Bytes  `json:"validators_hash"`
	AppHash            hexutil.Bytes  `json:"app_hash"`
	ReceiptsHash       hexutil.Bytes  `json:"receipts_hash"`
	LastNonEmptyHeight int64          `json:"last_non_empty_height"`
	CoinBase           hexutil.Bytes  `json:"coin_base"`

ResultHeader duplicates pbtypes.Header

func (*ResultHeader) Adapt

func (r *ResultHeader) Adapt(m *pbtypes.Header) *ResultHeader

type ResultInfo

type ResultInfo struct {
	Data             string        `json:"data"`
	Version          string        `json:"version"`
	LastBlockHeight  def.INT       `json:"last_block_height"`
	LastBlockAppHash hexutil.Bytes `json:"last_block_app_hash"`

type ResultNetInfo

type ResultNetInfo struct {
	Listening bool     `json:"listening"`
	Listeners []string `json:"listeners"`
	Peers     []*Peer  `json:"peers"`

type ResultNonEmptyHeights

type ResultNonEmptyHeights struct {
	Heights []def.INT `json:"heights"`

type ResultOrgs

type ResultOrgs struct {
	Names []string `json:"names"`

type ResultPartSetHeader

type ResultPartSetHeader struct {
	Total int32         `json:"total"`
	Hash  hexutil.Bytes `json:"hash"`

func (*ResultPartSetHeader) Adapt

type ResultQuery

type ResultQuery struct {
	Result Result `json:"result"`

ResultQuery is the result for all the raw query interface

type ResultQueryBalance

type ResultQueryBalance struct {
	Code    pbtypes.CodeType  `json:"code"`
	Log     string            `json:"log"`
	Balance *number.BigNumber `json:"balance"`

type ResultQueryContract

type ResultQueryContract struct {
	Code pbtypes.CodeType `json:"code"`
	Data string           `json:"data"`

type ResultQueryNonce

type ResultQueryNonce struct {
	Code  pbtypes.CodeType `json:"code"`
	Log   string           `json:"log"`
	Nonce uint64           `json:"nonce"`

type ResultQueryReceipt

type ResultQueryReceipt struct {
	Code    pbtypes.CodeType  `json:"code"`
	Log     string            `json:"log"`
	Receipt *ethtypes.Receipt `json:"receipt"`

type ResultQueryShare

type ResultQueryShare struct {
	Code          pbtypes.CodeType  `json:"code"`
	Log           string            `json:"log"`
	ShareBalance  *number.BigNumber `json:"share_balance"`
	ShareGuaranty *number.BigNumber `json:"share_guaranty"`
	GHeight       *number.BigNumber `json:"gheight"`

type ResultQueryTx

type ResultQueryTx struct {
	Code pbtypes.CodeType `json:"code"`
	Log  string           `json:"log"`
	Tx   *ResultBlockTx   `json:"tx"`

type ResultRefuseList

type ResultRefuseList struct {
	Result []string `json:"result"`

type ResultRequestSpecialOP

type ResultRequestSpecialOP struct {
	Code pbtypes.CodeType `json:"code"`
	Data hexutil.Bytes    `json:"data"`
	Log  string           `json:"log"`

type ResultStatus

type ResultStatus struct {
	NodeInfo          *p2p.NodeInfo `json:"node_info"`
	PubKey            crypto.PubKey `json:"pub_key"`
	LatestBlockHash   hexutil.Bytes `json:"latest_block_hash"`
	LatestAppHash     hexutil.Bytes `json:"latest_app_hash"`
	LatestBlockHeight def.INT       `json:"latest_block_height"`
	LatestBlockTime   int64         `json:"latest_block_time"` // nano

type ResultSubscribe

type ResultSubscribe struct {

type ResultSurveillance

type ResultSurveillance struct {
	NanoSecsPerTx time.Duration
	Height        def.INT
	Addr          string
	IsValidator   bool
	NumValidators int
	NumPeers      int
	RunningTime   time.Duration
	PubKey        string

type ResultTxEvmCommon

type ResultTxEvmCommon struct {
	To     hexutil.Bytes     `json:"to"`
	Amount *number.BigNumber `json:"amount"`
	Load   hexutil.Bytes     `json:"load"`

func (*ResultTxEvmCommon) Adapt

type ResultTxShareEco

type ResultTxShareEco struct {
	Source    hexutil.Bytes     `json:"source"`
	Amount    *number.BigNumber `json:"amount"`
	Signature hexutil.Bytes     `json:"signature"`

func (*ResultTxShareEco) Adapt

type ResultTxShareTransfer

type ResultTxShareTransfer struct {
	ShareSrc hexutil.Bytes     `json:"share_source"`
	ShareDst hexutil.Bytes     `json:"share_destination"`
	Amount   *number.BigNumber `json:"amount"`
	ShareSig hexutil.Bytes     `json:"share_signature"`

func (*ResultTxShareTransfer) Adapt

type ResultUnconfirmedTxs

type ResultUnconfirmedTxs struct {
	N   int  `json:"n_txs"`
	Txs []Tx `json:"txs"`

type ResultUnsafeFlushMempool

type ResultUnsafeFlushMempool struct{}

type ResultUnsafeProfile

type ResultUnsafeProfile struct{}

type ResultUnsafeSetConfig

type ResultUnsafeSetConfig struct{}

type ResultUnsubscribe

type ResultUnsubscribe struct {

type ResultValidator

type ResultValidator struct {
	Address     hexutil.Bytes `json:"address"`
	PubKey      hexutil.Bytes `json:"pub_key"`
	VotingPower def.INT       `json:"voting_power"`
	Accum       def.INT       `json:"accum"`
	IsCA        bool          `json:"is_ca"`

func (*ResultValidator) Adapt

type ResultValidatorSet

type ResultValidatorSet struct {
	Validators       []*ResultValidator `json:"validators"`
	Proposer         *ResultValidator   `json:"proposer"`
	TotalVotingPower def.INT            `json:"total_voting_power"`

func (*ResultValidatorSet) Adapt

type ResultValidators

type ResultValidators struct {
	BlockHeight def.INT      `json:"block_height"`
	Validators  []*Validator `json:"validators"`

type ResultVote

type ResultVote struct {
	Data      *ResultVoteData `json:"data"`
	Signature hexutil.Bytes   `json:"signature"`

func (*ResultVote) Adapt

func (r *ResultVote) Adapt(m *pbtypes.Vote) *ResultVote

type ResultVoteData

type ResultVoteData struct {
	ValidatorAddress hexutil.Bytes  `json:"validator_address"`
	ValidatorIndex   int64          `json:"validator_index"`
	Height           int64          `json:"height"`
	Round            int64          `json:"round"`
	Type             ResultVoteType `json:"type"`
	BlockID          *ResultBlockID `json:"block_id"`

func (*ResultVoteData) Adapt

type ResultVoteType

type ResultVoteType int32

type Signable

type Signable interface {
	// TODO rectify to buffer
	GetBytes(chainID string) ([]byte, error)

Signable is an interface for all signable things. It typically removes signatures before serializing.

type Signer

type Signer interface {
	Sign(msg []byte) crypto.Signature

This is used to sign votes. It is the caller's duty to verify the msg before calling Sign, eg. to avoid double signing. Currently, the only callers are SignVote and SignProposal

type SuspectTx

type SuspectTx struct {
	Suspect   *Hypocrite `json:"suspect"`
	PubKey    []byte     `json:"pubkey"`
	Signature []byte     `json:"signature"`

func (*SuspectTx) FromBytes

func (tx *SuspectTx) FromBytes(bs []byte) error

func (*SuspectTx) ToBytes

func (tx *SuspectTx) ToBytes() ([]byte, error)

type TMEventData

type TMEventData interface {

implements events.EventData

type Time

type Time struct {

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

func (*Time) String

func (t *Time) String() string

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) error

type Tx

type Tx []byte

func BytesToTxSlc

func BytesToTxSlc(txs [][]byte) []Tx

func (Tx) Hash

func (tx Tx) Hash() []byte

NOTE: this is the hash of the encoded Tx. Tx has no types at this level, so just length-prefixed. Alternatively, it may make sense to add types here and let []byte be type 0x1 so we can have versioned txs if need be in the future.

func (Tx) TxHash

func (tx Tx) TxHash() []byte

TxHash returns the hash without header. It is an unwrapped tx

type TxExecutionResult

type TxExecutionResult struct {
	Height        def.INT   `json:"height"`
	BlockHash     []byte    `json:"blockhash"`
	BlockTime     time.Time `json:"blocktime"`
	ValidatorHash []byte    `json:"validatorhash"`

func (*TxExecutionResult) FromBytes

func (i *TxExecutionResult) FromBytes(bytes []byte) error

func (*TxExecutionResult) ToBytes

func (i *TxExecutionResult) ToBytes() ([]byte, error)

type Txs

type Txs []Tx

func (Txs) Hash

func (txs Txs) Hash() []byte

func (Txs) ToBytes

func (txs Txs) ToBytes() [][]byte

type ValSetLoaderFunc

type ValSetLoaderFunc func(height, round def.INT) *ValidatorSet

type Validator

type Validator struct {
	Address     []byte          `json:"address"`
	PubKey      crypto.StPubKey `json:"pub_key"`
	VotingPower def.INT         `json:"voting_power"`
	Accum       def.INT         `json:"accum"`
	IsCA        bool            `json:"is_ca"`

Volatile state for each Validator TODO: make non-volatile identity

- Remove Accum - it can be computed, and now valset becomes identifying

func NewValidator

func NewValidator(pubKey crypto.PubKey, votingPower def.INT, isCA bool) *Validator

func (*Validator) Bytes

func (v *Validator) Bytes() []byte

func (*Validator) CompareAccum

func (v *Validator) CompareAccum(other *Validator) *Validator

Returns the one with higher Accum.

func (*Validator) Copy

func (v *Validator) Copy() *Validator

Creates a new copy of the validator so we can mutate accum. Panics if the validator is nil.

func (*Validator) CopyWithoutAccum

func (v *Validator) CopyWithoutAccum() *Validator

func (*Validator) GetPubKey

func (v *Validator) GetPubKey() crypto.PubKey

func (*Validator) Hash

func (v *Validator) Hash() []byte

func (*Validator) String

func (v *Validator) String() string

type ValidatorAttr

type ValidatorAttr struct {
	PubKey []byte `json:"pubKey,omitempty"`
	Power  uint64 `json:"power,omitempty"`
	IsCA   bool   `json:"isCA,omitempty"`

func (*ValidatorAttr) GetIsCA

func (m *ValidatorAttr) GetIsCA() bool

func (*ValidatorAttr) GetPower

func (m *ValidatorAttr) GetPower() uint64

func (*ValidatorAttr) GetPubKey

func (m *ValidatorAttr) GetPubKey() []byte

func (*ValidatorAttr) Reset

func (m *ValidatorAttr) Reset()

func (*ValidatorAttr) String

func (m *ValidatorAttr) String() string

type ValidatorSet

type ValidatorSet struct {
	Validators []*Validator // NOTE: persisted via reflect, must be exported.
	// contains filtered or unexported fields

ValidatorSet represent a set of *Validator at a given height. The validators can be fetched by address or index. The index is in order of .Address, so the indices are fixed for all rounds of a given blockchain height. On the other hand, the .AccumPower of each validator and the designated .Proposer() of a set changes every round, upon calling .IncrementAccum(). NOTE: Not goroutine-safe. NOTE: All get/set to validators should copy the value for safety. TODO: consider validator Accum overflow TODO: move valset into an iavl tree where key is 'blockbonded|pubkey'

func NewValidatorSet

func NewValidatorSet(vals []*Validator) *ValidatorSet

func ValSetFromJsonBytes

func ValSetFromJsonBytes(data []byte) *ValidatorSet

func ValSetFromPb

func ValSetFromPb(vslc *pbtypes.ValidatorSet) *ValidatorSet

func (*ValidatorSet) Add

func (valSet *ValidatorSet) Add(val *Validator) (added bool)

func (*ValidatorSet) Copy

func (valSet *ValidatorSet) Copy() *ValidatorSet

func (*ValidatorSet) CopyWithoutAccum

func (valSet *ValidatorSet) CopyWithoutAccum() *ValidatorSet

func (*ValidatorSet) GetByAddress

func (valSet *ValidatorSet) GetByAddress(address []byte) (index int, val *Validator)

func (*ValidatorSet) GetByIndex

func (valSet *ValidatorSet) GetByIndex(index int) (address []byte, val *Validator)

func (*ValidatorSet) HasAddress

func (valSet *ValidatorSet) HasAddress(address []byte) bool

func (*ValidatorSet) Hash

func (valSet *ValidatorSet) Hash() []byte

func (*ValidatorSet) IncrementAccum

func (valSet *ValidatorSet) IncrementAccum(times def.INT)

TODO: mind the overflow when times and votingPower shares too large.

func (*ValidatorSet) Iterate

func (valSet *ValidatorSet) Iterate(fn func(index int, val *Validator) bool)

func (*ValidatorSet) JSONBytes

func (valSet *ValidatorSet) JSONBytes() ([]byte, error)

func (*ValidatorSet) Proposer

func (valSet *ValidatorSet) Proposer() (proposer *Validator)

func (*ValidatorSet) Remove

func (valSet *ValidatorSet) Remove(address []byte) (val *Validator, removed bool)

func (*ValidatorSet) Size

func (valSet *ValidatorSet) Size() int

func (*ValidatorSet) String

func (valSet *ValidatorSet) String() string

func (*ValidatorSet) StringIndented

func (valSet *ValidatorSet) StringIndented(indent string) string

func (*ValidatorSet) ToPbVSet

func (vs *ValidatorSet) ToPbVSet() *pbtypes.ValidatorSet

func (*ValidatorSet) TotalVotingPower

func (valSet *ValidatorSet) TotalVotingPower() def.INT

func (*ValidatorSet) Update

func (valSet *ValidatorSet) Update(val *Validator) (updated bool)

func (*ValidatorSet) VerifyCommit

func (valSet *ValidatorSet) VerifyCommit(chainID string, blockID pbtypes.BlockID, height def.INT, commit *CommitCache) error

Verify that +2/3 of the set had signed the given signBytes

type ValidatorsByAddress

type ValidatorsByAddress []*Validator

func (ValidatorsByAddress) Len

func (vs ValidatorsByAddress) Len() int

func (ValidatorsByAddress) Less

func (vs ValidatorsByAddress) Less(i, j int) bool

func (ValidatorsByAddress) Swap

func (vs ValidatorsByAddress) Swap(i, j int)

type VoteSet

type VoteSet struct {
	// contains filtered or unexported fields

func NewVoteSet

func NewVoteSet(chainID string, height def.INT, round def.INT, type_ pbtypes.VoteType, valSet *ValidatorSet) *VoteSet

Constructs a new VoteSet struct used to accumulate votes for given height/round.

func (*VoteSet) AddVote

func (voteSet *VoteSet) AddVote(vote *pbtypes.Vote) (added bool, err error)

Returns added=true if vote is valid and new. Otherwise returns err=ErrVote[

UnexpectedStep | InvalidIndex | InvalidAddress |
InvalidSignature | InvalidBlockHash | ConflictingVotes ]

Duplicate votes return added=false, err=nil. Conflicting votes return added=*, err=ErrVoteConflictingVotes. NOTE: vote should not be mutated after adding. NOTE: VoteSet must not be nil

func (*VoteSet) BitArray

func (voteSet *VoteSet) BitArray() *BitArray

func (*VoteSet) BitArrayByBlockID

func (voteSet *VoteSet) BitArrayByBlockID(blockID *pbtypes.BlockID) *BitArray

func (*VoteSet) ChainID

func (voteSet *VoteSet) ChainID() string

func (*VoteSet) GetByAddress

func (voteSet *VoteSet) GetByAddress(address []byte) *pbtypes.Vote

func (*VoteSet) GetByIndex

func (voteSet *VoteSet) GetByIndex(valIndex int) *pbtypes.Vote

NOTE: if validator has conflicting votes, returns "canonical" vote

func (*VoteSet) HasAll

func (voteSet *VoteSet) HasAll() bool

func (*VoteSet) HasTwoThirdsAny

func (voteSet *VoteSet) HasTwoThirdsAny() bool

func (*VoteSet) HasTwoThirdsMajority

func (voteSet *VoteSet) HasTwoThirdsMajority() bool

func (*VoteSet) Height

func (voteSet *VoteSet) Height() def.INT

func (*VoteSet) IsCommit

func (voteSet *VoteSet) IsCommit() bool

func (*VoteSet) MakeCommit

func (voteSet *VoteSet) MakeCommit() *CommitCache

func (*VoteSet) Round

func (voteSet *VoteSet) Round() def.INT

func (*VoteSet) SetPeerMaj23

func (voteSet *VoteSet) SetPeerMaj23(peerID string, blockID *pbtypes.BlockID)

If a peer claims that it has 2/3 majority for given blockKey, call this. NOTE: if there are too many peers, or too much peer churn, this can cause memory issues. TODO: implement ability to remove peers too NOTE: VoteSet must not be nil

func (*VoteSet) Size

func (voteSet *VoteSet) Size() int

func (*VoteSet) String

func (voteSet *VoteSet) String() string

func (*VoteSet) StringIndented

func (voteSet *VoteSet) StringIndented(indent string) string

func (*VoteSet) StringShort

func (voteSet *VoteSet) StringShort() string

func (*VoteSet) TwoThirdsMajority

func (voteSet *VoteSet) TwoThirdsMajority() (blockID pbtypes.BlockID, ok bool)

Returns either a blockhash (or nil) that received +2/3 majority. If there exists no such majority, returns (nil, PartSetHeader{}, false).

func (*VoteSet) Type

func (voteSet *VoteSet) Type() pbtypes.VoteType

type VoteSetReader

type VoteSetReader interface {
	Height() def.INT
	Round() def.INT
	Type() pbtypes.VoteType
	Size() int
	BitArray() *BitArray
	GetByIndex(int) *pbtypes.Vote
	IsCommit() bool

Common interface between *consensus.VoteSet and types.Commit

Jump to

Keyboard shortcuts

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