ising

package
v0.3.18-alpha Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2018 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TxnAmountToBePackaged      = 1024
	WaitingForFloodingFinished = time.Second * 3
	WaitingForVotingFinished   = time.Second * 8
	TimeoutTolerance           = time.Second * 2
	ForkingDetectTimer         = time.Second * 5
	WaitingForProbeFinished    = time.Second * 3
	BlockRollbackStep          = 5
)
View Source
const (
	InitialBlockHeight = 5
)
View Source
const (
	MinPingRespNum = 3
)
View Source
const (
	MinSyncVotesNum = 3
)

Variables

This section is empty.

Functions

func BuildIsingPayload

func BuildIsingPayload(msg IsingMessage, sender *crypto.PubKey) (*message.IsingPayload, error)

func HasAbilityToVerifyBlock

func HasAbilityToVerifyBlock(block *ledger.Block) bool

HasAbilityToVerifyBlock checks if local node can verify the block.

func HeightHashToString

func HeightHashToString(height uint32, blockHash Uint256) string

HeightHashToString uses block height and block hash to generate a uniq string

func StringToHeightHash

func StringToHeightHash(str string) (uint32, Uint256)

StringToHeightHash recovers block height and block hash from string which generated by HeightHashToString

Types

type BlockFlooding

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

func NewBlockFlooding

func NewBlockFlooding(block *ledger.Block) *BlockFlooding

func (*BlockFlooding) Deserialize

func (bf *BlockFlooding) Deserialize(r io.Reader) error

func (*BlockFlooding) Serialize

func (bf *BlockFlooding) Serialize(w io.Writer) error

type BlockInfo

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

type BuiltinMining

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

func NewBuiltinMining

func NewBuiltinMining(account *vault.Account, txnCollector *transaction.TxnCollector) *BuiltinMining

func (*BuiltinMining) BuildBlock

func (bm *BuiltinMining) BuildBlock(height uint32, chordID []byte, winningHash Uint256,
	winningHashType ledger.WinningHashType) (*ledger.Block, error)

func (*BuiltinMining) CreateCoinbaseTransaction

func (bm *BuiltinMining) CreateCoinbaseTransaction() *transaction.Transaction

type ForkCache

type ForkCache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewForkCache

func NewForkCache(height uint32, hash Uint256) *ForkCache

func (*ForkCache) AnalyzePingResp

func (fc *ForkCache) AnalyzePingResp() bool

func (*ForkCache) AnalyzeProbeResp

func (fc *ForkCache) AnalyzeProbeResp() bool

func (*ForkCache) CachePingResp

func (fc *ForkCache) CachePingResp(hash Uint256, height uint32, sender uint64) error

func (*ForkCache) CacheProbeResp

func (fc *ForkCache) CacheProbeResp(hash Uint256, height uint32, sender uint64) error

func (*ForkCache) GetCurrentHeight

func (fc *ForkCache) GetCurrentHeight() uint32

func (*ForkCache) GetRollBackHeight

func (fc *ForkCache) GetRollBackHeight() uint32

func (*ForkCache) SetRollBackHeight

func (fc *ForkCache) SetRollBackHeight(height uint32)

type IsingMessage

type IsingMessage interface {
	serialization.SerializableData
}

func RecoverFromIsingPayload

func RecoverFromIsingPayload(payload *message.IsingPayload) (IsingMessage, error)

type IsingMessageType

type IsingMessageType byte
const (
	BlockFloodingMsg IsingMessageType = 0x00
	BlockRequestMsg  IsingMessageType = 0x01
	BlockResponseMsg IsingMessageType = 0x02
	BlockProposalMsg IsingMessageType = 0x03
	MindChangingMsg  IsingMessageType = 0x04
	PingMsg          IsingMessageType = 0x07
	PongMsg          IsingMessageType = 0x08
)

type MindChanging

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

func NewMindChanging

func NewMindChanging(hash *Uint256, height uint32, ctype voting.VotingContentType) *MindChanging

func (*MindChanging) Deserialize

func (mc *MindChanging) Deserialize(r io.Reader) error

func (*MindChanging) Serialize

func (mc *MindChanging) Serialize(w io.Writer) error

type Mining

type Mining interface {
	BuildBlock(height uint32, chordID []byte, winningHash Uint256,
		winningHashType ledger.WinningHashType) (*ledger.Block, error)
}

type Ping

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

func NewPing

func NewPing(height uint32) *Ping

func (*Ping) Deserialize

func (p *Ping) Deserialize(r io.Reader) error

func (*Ping) Serialize

func (p *Ping) Serialize(w io.Writer) error

type Pong

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

func NewPong

func NewPong(hash Uint256, height uint32, pingHeight uint32) *Pong

func (*Pong) Deserialize

func (p *Pong) Deserialize(r io.Reader) error

func (*Pong) Serialize

func (p *Pong) Serialize(w io.Writer) error

type Proposal

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

func NewProposal

func NewProposal(hash *Uint256, height uint32, ctype voting.VotingContentType) *Proposal

func (*Proposal) Deserialize

func (p *Proposal) Deserialize(r io.Reader) error

func (*Proposal) Serialize

func (p *Proposal) Serialize(w io.Writer) error

type ProposerCache

type ProposerCache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewProposerCache

func NewProposerCache() *ProposerCache

func (*ProposerCache) Add

func (pc *ProposerCache) Add(height uint32, votingContent voting.VotingContent)

func (*ProposerCache) Get

func (pc *ProposerCache) Get(height uint32) *ProposerInfo

type ProposerInfo

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

type ProposerService

type ProposerService struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewProposerService

func NewProposerService(account *vault.Account, node protocol.Noder) *ProposerService

func (*ProposerService) BlockPersistCompleted

func (ps *ProposerService) BlockPersistCompleted(v interface{})

func (*ProposerService) BlockSyncingFinished

func (ps *ProposerService) BlockSyncingFinished(v interface{})

func (*ProposerService) ChangeProposerRoutine

func (ps *ProposerService) ChangeProposerRoutine()

func (*ProposerService) ConsensusRoutine

func (ps *ProposerService) ConsensusRoutine(vType voting.VotingContentType, isProposer bool)

func (*ProposerService) CurrentVoting

func (ps *ProposerService) CurrentVoting(vType voting.VotingContentType) voting.Voting

func (*ProposerService) GetReceiverNode

func (ps *ProposerService) GetReceiverNode(nids []uint64) []protocol.Noder

GetReceiverNode returns neighbors nodes according to neighbor node ID passed in. If 'nids' passed in is nil then returns all neighbor nodes.

func (*ProposerService) HandleBlockFloodingMsg

func (ps *ProposerService) HandleBlockFloodingMsg(bfMsg *BlockFlooding, sender uint64)

func (*ProposerService) HandleBlockForking

func (ps *ProposerService) HandleBlockForking()

func (*ProposerService) HandleMindChangingMsg

func (ps *ProposerService) HandleMindChangingMsg(mindChanging *MindChanging, sender uint64)

func (*ProposerService) HandlePingMsg

func (ps *ProposerService) HandlePingMsg(msg *Ping, sender uint64)

func (*ProposerService) HandlePongMsg

func (ps *ProposerService) HandlePongMsg(msg *Pong, sender uint64)

func (*ProposerService) HandleProposalMsg

func (ps *ProposerService) HandleProposalMsg(proposal *Proposal, sender uint64)

func (*ProposerService) HandleRequestMsg

func (ps *ProposerService) HandleRequestMsg(req *Request, sender uint64)

func (*ProposerService) HandleResponseMsg

func (ps *ProposerService) HandleResponseMsg(resp *Response, sender uint64)

func (*ProposerService) Initialize

func (ps *ProposerService) Initialize(vType voting.VotingContentType)

func (*ProposerService) IsBlockProposer

func (ps *ProposerService) IsBlockProposer() bool

func (*ProposerService) PersistCachedBlock

func (ps *ProposerService) PersistCachedBlock(height uint32) error

func (*ProposerService) ProcessRollback

func (ps *ProposerService) ProcessRollback()

func (*ProposerService) ProduceNewBlock

func (ps *ProposerService) ProduceNewBlock()

func (*ProposerService) ProposerRoutine

func (ps *ProposerService) ProposerRoutine()

func (*ProposerService) ReceiveConsensusMsg

func (ps *ProposerService) ReceiveConsensusMsg(v interface{})

func (*ProposerService) SendConsensusMsg

func (ps *ProposerService) SendConsensusMsg(msg IsingMessage, to []protocol.Noder) error

func (*ProposerService) SendNewProposal

func (ps *ProposerService) SendNewProposal(votingHeight uint32, vType voting.VotingContentType, isProposer bool) error

func (*ProposerService) SetOrChangeMind

func (ps *ProposerService) SetOrChangeMind(votingType voting.VotingContentType,
	votingHeight uint32, maybeFinalHash *Uint256)

func (*ProposerService) Start

func (ps *ProposerService) Start() error

func (*ProposerService) SyncBlock

func (ps *ProposerService) SyncBlock(isProposer bool)

func (*ProposerService) TimeoutRoutine

func (ps *ProposerService) TimeoutRoutine()

type Request

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

func NewRequest

func NewRequest(hash *Uint256, height uint32, ctype voting.VotingContentType) *Request

func (*Request) Deserialize

func (req *Request) Deserialize(r io.Reader) error

func (*Request) Serialize

func (req *Request) Serialize(w io.Writer) error

type Response

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

func NewResponse

func NewResponse(hash *Uint256, height uint32, ctype voting.VotingContentType, content voting.VotingContent) *Response

func (*Response) Deserialize

func (resp *Response) Deserialize(r io.Reader) error

func (*Response) Serialize

func (resp *Response) Serialize(w io.Writer) error

type SyncCache

type SyncCache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

SyncCache cached blocks sent by block proposer when wait for block syncing finished.

func NewSyncBlockCache

func NewSyncBlockCache() *SyncCache

func (*SyncCache) AddBlockToSyncCache

func (sc *SyncCache) AddBlockToSyncCache(block *ledger.Block, rtime int64) error

AddBlockToSyncCache caches received block and the voter count when receive block. Returns nil if block already existed.

func (*SyncCache) AddVoteForBlock

func (sc *SyncCache) AddVoteForBlock(hash Uint256, height uint32, voter uint64) bool

AddVoteForBlock adds vote for block when receive valid proposal.

func (*SyncCache) BlockInSyncCache

func (sc *SyncCache) BlockInSyncCache(hash Uint256, height uint32) (*BlockInfo, bool)

BlockInSyncCache returns block info and true is the block exists in cache.

func (*SyncCache) CachedBlockHeight

func (sc *SyncCache) CachedBlockHeight() int

CachedBlockHeight returns cached block height.

func (*SyncCache) ChangeVoteForBlock

func (sc *SyncCache) ChangeVoteForBlock(hash Uint256, height uint32, voter uint64) error

ChangeVoteForBlock change vote for block when receive valid mind changing.

func (*SyncCache) GetBlock

func (sc *SyncCache) GetBlock(height uint32, hash *Uint256) (*ledger.Block, error)

func (*SyncCache) RemoveBlockFromCache

func (sc *SyncCache) RemoveBlockFromCache(height uint32) error

RemoveBlockFromCache removes cached block which height is minimum.

func (*SyncCache) SetConsensusHeight

func (sc *SyncCache) SetConsensusHeight(height uint32)

func (*SyncCache) WaitBlockVotingFinished

func (sc *SyncCache) WaitBlockVotingFinished(height uint32) (*ledger.VBlock, error)

WaitBlockVotingFinished returns cached block by height.

type TimeLock

type TimeLock struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewTimeLock

func NewTimeLock() *TimeLock

func (*TimeLock) LockForHeight

func (tl *TimeLock) LockForHeight(height uint32, timer *time.Timer)

func (*TimeLock) RemoveForHeight

func (tl *TimeLock) RemoveForHeight(height uint32)

func (*TimeLock) WaitForTimeout

func (tl *TimeLock) WaitForTimeout(height uint32) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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