shard

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2019 License: LGPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnManager

type ConnManager interface {
	BroadcastXshardTxList(block *types.MinorBlock, xshardTxList []*types.CrossShardTransactionDeposit, height uint32) error
	SendMinorBlockHeaderToMaster(minorHeader *types.MinorBlockHeader, txLen, xshardLen uint32, state *rpc.ShardStatus) error
	BatchBroadcastXshardTxList(blokHshToXLstAdPrvRotHg map[common.Hash]*XshardListTuple, sorBrch account.Branch) error
	// p2p interface
	BroadcastNewTip(mHeaderLst []*types.MinorBlockHeader, rHeader *types.RootBlockHeader, branch uint32) error
	BroadcastTransactions(txs []*types.Transaction, branch uint32) error
	BroadcastMinorBlock(minorBlock *types.MinorBlock, branch uint32) error
	GetMinorBlocks(mHeaderList []common.Hash, peerId string, branch uint32) ([]*types.MinorBlock, error)
	GetMinorBlockHeaders(*rpc.GetMinorBlockHeaderListRequest) ([]*types.MinorBlockHeader, error)
}

type ShardBackend

type ShardBackend struct {
	Config *config.ShardConfig

	MinorBlockChain *core.MinorBlockChain
	// contains filtered or unexported fields
}

func New

func New(ctx *service.ServiceContext, rBlock *types.RootBlock, conn ConnManager,
	cfg *config.ClusterConfig, fullshardId uint32) (*ShardBackend, error)

func (*ShardBackend) AddBlockListForSync

func (s *ShardBackend) AddBlockListForSync(blockLst []*types.MinorBlock) error

Add blocks in batch to reduce RPCs. Will NOT broadcast to peers.

Returns true if blocks are successfully added. False on any error. This function only adds blocks to local and propagate xshard list to other shards. It does NOT notify master because the master should already have the minor header list, and will add them once this function returns successfully.

func (*ShardBackend) AddMinorBlock

func (s *ShardBackend) AddMinorBlock(block *types.MinorBlock) error

Returns true if block is successfully added. False on any error. called by 1. local miner (will not run if syncing) 2. SyncTask

func (*ShardBackend) AddRootBlock

func (s *ShardBackend) AddRootBlock(rBlock *types.RootBlock) (switched bool, err error)

func (*ShardBackend) CreateBlockToMine

func (s *ShardBackend) CreateBlockToMine() (types.IBlock, error)

miner api

func (*ShardBackend) GenTx

func (s *ShardBackend) GenTx(genTxs *rpc.GenTxRequest) error

func (*ShardBackend) GetLogs

func (s *ShardBackend) GetLogs(start uint64, end uint64, address []account.Address, topics [][]common.Hash) ([]*types.Log, error)

TODO 当前版本暂不添加

func (*ShardBackend) GetMinorBlock

func (s *ShardBackend) GetMinorBlock(mHash common.Hash, height *uint64) *types.MinorBlock

func (*ShardBackend) GetTip

func (s *ShardBackend) GetTip() uint64

func (*ShardBackend) GetTransactionListByAddress

func (s *ShardBackend) GetTransactionListByAddress(address *account.Address,
	start []byte, limit uint32) ([]*rpc.TransactionDetail, []byte, error)

func (*ShardBackend) GetUnconfirmedHeaderList

func (s *ShardBackend) GetUnconfirmedHeaderList() ([]*types.MinorBlockHeader, error)

func (*ShardBackend) GetWork

func (s *ShardBackend) GetWork() (*consensus.MiningWork, error)

func (*ShardBackend) HandleNewTip

func (s *ShardBackend) HandleNewTip(rBHeader *types.RootBlockHeader, mBHeader *types.MinorBlockHeader, peerID string) error

func (*ShardBackend) InitFromRootBlock

func (s *ShardBackend) InitFromRootBlock(rBlock *types.RootBlock) error

Either recover state from local db or create genesis state based on config

func (*ShardBackend) InsertMinedBlock

func (s *ShardBackend) InsertMinedBlock(block types.IBlock) error

func (*ShardBackend) NewMinorBlock

func (s *ShardBackend) NewMinorBlock(block *types.MinorBlock) (err error)

func (*ShardBackend) PoswDiffAdjust

func (s *ShardBackend) PoswDiffAdjust(block *types.MinorBlock) (*big.Int, error)

func (*ShardBackend) SetMining

func (s *ShardBackend) SetMining(mining bool)

func (*ShardBackend) Stop

func (s *ShardBackend) Stop()

func (*ShardBackend) SubmitWork

func (s *ShardBackend) SubmitWork(headerHash common.Hash, nonce uint64, mixHash common.Hash) error

type TxGenerator

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

func NewTxGenerator

func NewTxGenerator(genesisDir string, fullShardId uint32, cfg *config.QuarkChainConfig) *TxGenerator

func (*TxGenerator) Generate

func (t *TxGenerator) Generate(genTxs *rpc.GenTxRequest, addTxList func(txs []*types.Transaction) error) error

type XshardListTuple

type XshardListTuple struct {
	XshardTxList   []*types.CrossShardTransactionDeposit
	PrevRootHeight uint32
}

Jump to

Keyboard shortcuts

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