framework

package
v0.0.0-...-667e438 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenDeliverFromNode

func GenDeliverFromNode(theNode *node.NodeEngine, secCtx string, attrs ...string) (deliverToNetwork, error)

create deliver from default peer of the node

func NewBaseLedgerLearner

func NewBaseLedgerLearner(l *ledger.Ledger, peer *node.PeerEngine, cfg FrameworkConfig) *baseLearnerImpl

Types

type ConsensusBase

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

func NewConsensusBase

func NewConsensusBase(topic litekfk.Topic) *ConsensusBase

func NewConsensusBaseNake

func NewConsensusBaseNake(cfg FrameworkConfig) *ConsensusBase

func (*ConsensusBase) BuildBaseProposalRoutine

func (cb *ConsensusBase) BuildBaseProposalRoutine(miner ConsensusProposal,
	deliver ConsensusTxDeliver, batchLimit int, sourceCli ...*litekfk.Client) ProposalFunc

an default handling for purposing (mining) which can be handled in idle time of mainroutine, it was a very base one which do nothing extra (for example: prepare for the newstate) the reason that mining only run when main routine is idle is node is difficult to made reasonable block when it was just busy for catching the latest state this method generate

func (*ConsensusBase) MainRoutine

func (cb *ConsensusBase) MainRoutine(ctx context.Context, learner LedgerLearner)

main routine act as an handler for each consensus tx, drive a learner to make ledger and state go forward

func (*ConsensusBase) MakeScheme

func (cb *ConsensusBase) MakeScheme(ne *node.NodeEngine, ccname string)

func (*ConsensusBase) ProposeEntry

func (cb *ConsensusBase) ProposeEntry() chan<- ProposalTask

type ConsensusHistory

type ConsensusHistory []byte

type ConsensusProposal

type ConsensusProposal interface {
	//input a group of transaction (and their handling context) to create
	//the real consensus transaction, currently the puprposer CAN NOT rejected part of
	//txs in input. It must accept or rejected them at all
	//DO NOT CALL methods of the input ledgerlearnerinfo outside of propose (for example, run
	//them in an spawned goroutine) or we may got race-condition on the target ledger
	//which binding to the learner
	Propose(cspb.PendingTransactions, LedgerLearnerInfo) <-chan *cspb.ConsensusPurpose
	//interrupt the proposal by an external call
	Cancel()
}

wrap the interface of miner

type ConsensusState

type ConsensusState []byte

type ConsensusTxDeliver

type ConsensusTxDeliver interface {
	Send(context.Context, []*pb.Transaction) error
}

wrap the interface for delivering generated transactions, often it can be just wrap of the client service module when tx is delivered, it will be treated as other consensus tx received from txnetwork and handled by learner

type ErrorWriteBack

type ErrorWriteBack struct{}

writeback error indicate CURRENT handling txe do not being handled and should be put later (generally, after a Trigger call with true return)

func (ErrorWriteBack) Error

func (ErrorWriteBack) Error() string

type FrameworkConfig

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

func NewConfig

func NewConfig(vp *viper.Viper) FrameworkConfig

func (FrameworkConfig) SubConfig

func (c FrameworkConfig) SubConfig(sub string) *viper.Viper

type LedgerLearner

type LedgerLearner interface {
	LedgerLearnerInfo

	//put is allowed to block for CERTAIN (limited) time
	//it may return three results for a tx:
	//* learner consume the incoming tx and success (return nil)
	//* learner consume incoming tx but fail (return error)
	//* writeback, learner return one (or more) tx and calle should postpone
	//  their delivery
	Put(context.Context, *pb.TransactionHandlingContext) error

	//put direct allow external calling directly input some result,
	//to drive the ledger/status wrapped inside learner go forward
	//forexample, ConsensusBase allow deliver any custom process
	//which is able to access the learner directly. Such a process can
	//make use of this entry
	PutDirect(context.Context, *cspb.ConsensusOutput) error

	//trigger make learner to resolve its pending task, even no new
	//consensus tx is input
	//it is also help caller to decide if writeback tx should be delivered
	//again: a trigger return false indicate there is still pending
	//tasks and no progress is made
	Trigger(context.Context) bool
}

a ledger learner accept incoming consensus tx and update A ledger

type LedgerLearnerInfo

type LedgerLearnerInfo interface {

	//help to built a preview block, which contain the essential data
	//(previousblock, transactions, statehashes, nonhashdata, etc)
	//learner can also cache build candidate so it is not need to do evaluation
	//again
	Preview(context.Context, uint64, []*pb.TransactionHandlingContext) (*pb.Block, error)
	//previewsimple only build the mininal fields of the block from input txes,
	//it do not evaluate any transaction nor prepare for statehash
	PreviewSimple([]*pb.TransactionHandlingContext) *pb.Block

	Ledger() *ledger.Ledger

	//just a fast entry for many miner, incidate the newest history's hash it has
	//learn so miner can mine new block on top of it
	//if there is no avaliable history, just return nil
	HistoryTop() (uint64, []byte)
}

type ProposalFunc

type ProposalFunc func() func(context.Context) error

BuildBaseProposalRoutine return this type for trigger a new proposal progress the function can be called mutiple times and after each calling user MUST wait the returned wait function for another call, or undefined behaviour will be raised. use can passed a done context to wait function, which will try to stop current running proposal progress as soon as possible

type ProposalTask

type ProposalTask func(context.Context, LedgerLearnerInfo)

type ResumedDelivery

type ResumedDelivery interface {
	Resume(context.Context) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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