master

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: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QKCProtocolName    = "quarkchain"
	QKCProtocolVersion = 1
	QKCProtocolLength  = 16
)

QKCProtocol details

Variables

View Source
var (
	ErrNoBranchConn = errors.New("no such branch's connection")
)

Functions

This section is empty.

Types

type MasterServerSideOp

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

func NewServerSideOp

func NewServerSideOp(master *QKCMasterBackend) *MasterServerSideOp

func (*MasterServerSideOp) AddMinorBlockHeader

func (m *MasterServerSideOp) AddMinorBlockHeader(ctx context.Context, req *rpc.Request) (*rpc.Response, error)

func (*MasterServerSideOp) BroadcastNewMinorBlock

func (m *MasterServerSideOp) BroadcastNewMinorBlock(ctx context.Context, req *rpc.Request) (*rpc.Response, error)

func (*MasterServerSideOp) BroadcastNewTip

func (m *MasterServerSideOp) BroadcastNewTip(ctx context.Context, req *rpc.Request) (*rpc.Response, error)

p2p apis

func (*MasterServerSideOp) BroadcastTransactions

func (m *MasterServerSideOp) BroadcastTransactions(ctx context.Context, req *rpc.Request) (*rpc.Response, error)

func (*MasterServerSideOp) GetMinorBlockHeaderList

func (m *MasterServerSideOp) GetMinorBlockHeaderList(ctx context.Context, req *rpc.Request) (*rpc.Response, error)

func (*MasterServerSideOp) GetMinorBlockList

func (m *MasterServerSideOp) GetMinorBlockList(ctx context.Context, req *rpc.Request) (*rpc.Response, error)

type PrivateP2PAPI

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

func NewPrivateP2PAPI

func NewPrivateP2PAPI(peers *peerSet) *PrivateP2PAPI

NewPrivateP2PAPI creates a new peer shard p2p protocol API.

func (*PrivateP2PAPI) BroadcastMinorBlock

func (api *PrivateP2PAPI) BroadcastMinorBlock(branch uint32, block *types.MinorBlock) error

BroadcastMinorBlock will be called when a minor block first time added to a chain

func (*PrivateP2PAPI) BroadcastNewTip

func (api *PrivateP2PAPI) BroadcastNewTip(branch uint32, rootBlockHeader *types.RootBlockHeader, minorBlockHeaderList []*types.MinorBlockHeader) error

func (*PrivateP2PAPI) BroadcastTransactions

func (api *PrivateP2PAPI) BroadcastTransactions(branch uint32, txs []*types.Transaction)

BroadcastTransactions only be called when run performance test which the txs are created by shard itself, so broadcast to all the peer

func (*PrivateP2PAPI) GetMinorBlockHeaders

func (api *PrivateP2PAPI) GetMinorBlockHeaders(hash common.Hash, amount uint32, branch uint32, reverse bool, peerId string) ([]*types.MinorBlockHeader, error)

func (*PrivateP2PAPI) GetMinorBlockList

func (api *PrivateP2PAPI) GetMinorBlockList(hashList []common.Hash, branch uint32, peerId string) ([]*types.MinorBlock, error)

type ProtocolManager

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

ProtocolManager QKC manager

func NewProtocolManager

func NewProtocolManager(env config.ClusterConfig, rootBlockChain *core.RootBlockChain, statsChan chan *rpc.ShardStatus, synchronizer synchronizer.Synchronizer, getShardConnFunc func(fullShardId uint32) []rpc.ShardConnForP2P) (*ProtocolManager, error)

NewQKCManager new qkc manager

func (*ProtocolManager) BroadcastTip

func (pm *ProtocolManager) BroadcastTip(header *types.RootBlockHeader)

func (*ProtocolManager) BroadcastTransactions

func (pm *ProtocolManager) BroadcastTransactions(branch uint32, txs []*types.Transaction, sourcePeerId string)

func (*ProtocolManager) HandleGetMinorBlockHeaderListRequest

func (pm *ProtocolManager) HandleGetMinorBlockHeaderListRequest(rpcId uint64, branch uint32, request *p2p.GetMinorBlockHeaderListRequest) (*p2p.GetMinorBlockHeaderListResponse, error)

func (*ProtocolManager) HandleGetMinorBlockListRequest

func (pm *ProtocolManager) HandleGetMinorBlockListRequest(peerId string, rpcId uint64, branch uint32, request *p2p.GetMinorBlockListRequest) (*p2p.GetMinorBlockListResponse, error)

func (*ProtocolManager) HandleGetRootBlockHeaderListRequest

func (pm *ProtocolManager) HandleGetRootBlockHeaderListRequest(blockHeaderReq *p2p.GetRootBlockHeaderListRequest) (*p2p.GetRootBlockHeaderListResponse, error)

func (*ProtocolManager) HandleGetRootBlockListRequest

func (pm *ProtocolManager) HandleGetRootBlockListRequest(request *p2p.GetRootBlockListRequest) (*p2p.GetRootBlockListResponse, error)

func (*ProtocolManager) HandleNewMinorTip

func (pm *ProtocolManager) HandleNewMinorTip(branch uint32, tip *p2p.Tip, peer *peer) error

func (*ProtocolManager) HandleNewRootTip

func (pm *ProtocolManager) HandleNewRootTip(tip *p2p.Tip, peer *peer) error

func (*ProtocolManager) HandleNewTransactionListRequest

func (pm *ProtocolManager) HandleNewTransactionListRequest(peerId string, rpcId uint64, branch uint32, request *p2p.NewTransactionList) error

func (*ProtocolManager) Start

func (pm *ProtocolManager) Start(maxPeers int)

Start manager start

func (*ProtocolManager) Stop

func (pm *ProtocolManager) Stop()

type QKCMasterBackend

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

QKCMasterBackend masterServer include connections

func New

New new master with config

func (*QKCMasterBackend) APIs

func (s *QKCMasterBackend) APIs() []ethRPC.API

APIs return all apis for master Server

func (*QKCMasterBackend) AddRootBlock

func (s *QKCMasterBackend) AddRootBlock(rootBlock *types.RootBlock) error

AddRootBlock add root block to all slaves

func (*QKCMasterBackend) AddTransaction

func (s *QKCMasterBackend) AddTransaction(tx *types.Transaction) error

func (*QKCMasterBackend) ConnectToSlaves

func (s *QKCMasterBackend) ConnectToSlaves() error

func (*QKCMasterBackend) CreateBlockToMine

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

miner api

func (*QKCMasterBackend) CreateTransactions

func (s *QKCMasterBackend) CreateTransactions(numTxPerShard, xShardPercent uint32, tx *types.Transaction) error

CreateTransactions Create transactions and add to the network for load testing

func (*QKCMasterBackend) CurrentBlock

func (s *QKCMasterBackend) CurrentBlock() *types.RootBlock

func (*QKCMasterBackend) EstimateGas

func (s *QKCMasterBackend) EstimateGas(tx *types.Transaction, fromAddress *account.Address) (uint32, error)

func (*QKCMasterBackend) ExecuteTransaction

func (s *QKCMasterBackend) ExecuteTransaction(tx *types.Transaction, address *account.Address, height *uint64) ([]byte, error)

func (*QKCMasterBackend) GasPrice

func (s *QKCMasterBackend) GasPrice(branch account.Branch) (uint64, error)

func (*QKCMasterBackend) GetAccountData

func (s *QKCMasterBackend) GetAccountData(address *account.Address, height *uint64) (map[uint32]*rpc.AccountBranchData, error)

GetAccountData get account Data for jsonRpc

func (*QKCMasterBackend) GetBlockCount

func (s *QKCMasterBackend) GetBlockCount() (map[uint32]map[account.Recipient]uint32, error)

func (*QKCMasterBackend) GetClusterConfig

func (s *QKCMasterBackend) GetClusterConfig() *config.ClusterConfig

func (*QKCMasterBackend) GetCode

func (s *QKCMasterBackend) GetCode(address *account.Address, height *uint64) ([]byte, error)

func (*QKCMasterBackend) GetLastMinorBlockByFullShardID

func (s *QKCMasterBackend) GetLastMinorBlockByFullShardID(fullShardId uint32) (uint64, error)

func (*QKCMasterBackend) GetLogs

func (s *QKCMasterBackend) GetLogs(branch account.Branch, address []account.Address, topics [][]common.Hash, startBlockNumber, endBlockNumber uint64) ([]*types.Log, error)

func (*QKCMasterBackend) GetMinorBlockByHash

func (s *QKCMasterBackend) GetMinorBlockByHash(blockHash common.Hash, branch account.Branch) (*types.MinorBlock, error)

func (*QKCMasterBackend) GetMinorBlockByHeight

func (s *QKCMasterBackend) GetMinorBlockByHeight(height *uint64, branch account.Branch) (*types.MinorBlock, error)

func (*QKCMasterBackend) GetPeers

func (s *QKCMasterBackend) GetPeers() []rpc.PeerInfoForDisPlay

func (*QKCMasterBackend) GetPrimaryAccountData

func (s *QKCMasterBackend) GetPrimaryAccountData(address *account.Address, blockHeight *uint64) (*rpc.AccountBranchData, error)

GetPrimaryAccountData get primary account data for jsonRpc

func (*QKCMasterBackend) GetRootBlockByHash

func (s *QKCMasterBackend) GetRootBlockByHash(hash common.Hash) (*types.RootBlock, error)

func (*QKCMasterBackend) GetRootBlockByNumber

func (s *QKCMasterBackend) GetRootBlockByNumber(blockNumber *uint64) (*types.RootBlock, error)

func (*QKCMasterBackend) GetSlavePoolLen

func (s *QKCMasterBackend) GetSlavePoolLen() int

func (*QKCMasterBackend) GetStats

func (s *QKCMasterBackend) GetStats() (map[string]interface{}, error)

func (*QKCMasterBackend) GetStorageAt

func (s *QKCMasterBackend) GetStorageAt(address *account.Address, key common.Hash, height *uint64) (common.Hash, error)

func (*QKCMasterBackend) GetTip

func (s *QKCMasterBackend) GetTip() uint64

func (*QKCMasterBackend) GetTransactionByHash

func (s *QKCMasterBackend) GetTransactionByHash(txHash common.Hash, branch account.Branch) (*types.MinorBlock, uint32, error)

func (*QKCMasterBackend) GetTransactionReceipt

func (s *QKCMasterBackend) GetTransactionReceipt(txHash common.Hash, branch account.Branch) (*types.MinorBlock, uint32, *types.Receipt, error)

func (*QKCMasterBackend) GetTransactionsByAddress

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

func (*QKCMasterBackend) GetWork

func (s *QKCMasterBackend) GetWork(branch account.Branch) (*consensus.MiningWork, error)

return root chain work if branch is nil

func (*QKCMasterBackend) Heartbeat

func (s *QKCMasterBackend) Heartbeat()

func (*QKCMasterBackend) Init

func (s *QKCMasterBackend) Init(srvr *p2p.Server) error

Start start node -> start qkcMaster

func (*QKCMasterBackend) InsertMinedBlock

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

func (*QKCMasterBackend) IsMining

func (s *QKCMasterBackend) IsMining() bool

func (*QKCMasterBackend) IsSyncing

func (s *QKCMasterBackend) IsSyncing() bool

func (*QKCMasterBackend) NetWorkInfo

func (s *QKCMasterBackend) NetWorkInfo() map[string]interface{}

func (*QKCMasterBackend) Protocols

func (s *QKCMasterBackend) Protocols() []p2p.Protocol

Protocols p2p protocols, p2p Server will start in node.Start

func (*QKCMasterBackend) SendMiningConfigToSlaves

func (s *QKCMasterBackend) SendMiningConfigToSlaves(mining bool) error

SendMiningConfigToSlaves send mining config to slaves,used in jsonRpc

func (*QKCMasterBackend) SetMining

func (s *QKCMasterBackend) SetMining(mining bool)

func (*QKCMasterBackend) SetTargetBlockTime

func (s *QKCMasterBackend) SetTargetBlockTime(rootBlockTime *uint32, minorBlockTime *uint32) error

SetTargetBlockTime set target Time from jsonRpc

func (*QKCMasterBackend) Start

func (s *QKCMasterBackend) Start() error

InitCluster init cluster : 1:ConnectToSlaves 2:logSummary 3:check if has all shards 4.setup slave to slave 5:init shards

func (*QKCMasterBackend) Stop

func (s *QKCMasterBackend) Stop() error

Stop stop node -> stop qkcMaster

func (*QKCMasterBackend) SubmitWork

func (s *QKCMasterBackend) SubmitWork(branch account.Branch, headerHash common.Hash, nonce uint64, mixHash common.Hash) (bool, error)

submit root chain work if branch is nil

func (*QKCMasterBackend) UpdateShardStatus

func (s *QKCMasterBackend) UpdateShardStatus(status *rpc.ShardStatus)

UpdateShardStatus update shard status for branchg

func (*QKCMasterBackend) UpdateTxCountHistory

func (s *QKCMasterBackend) UpdateTxCountHistory(txCount, xShardTxCount uint32, createTime uint64)

UpdateTxCountHistory update Tx count queue

type SlaveConnection

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

func NewSlaveConn

func NewSlaveConn(target string, shardMaskList []*types.ChainMask, slaveID string) *SlaveConnection

create slave connection manager

func (*SlaveConnection) AddBlockListForSync

func (s *SlaveConnection) AddBlockListForSync(request *rpc.AddBlockListForSyncRequest) (*rpc.ShardStatus, error)

func (*SlaveConnection) AddRootBlock

func (s *SlaveConnection) AddRootBlock(rootBlock *types.RootBlock, expectSwitch bool) error

func (*SlaveConnection) AddTransaction

func (s *SlaveConnection) AddTransaction(tx *types.Transaction) error

func (*SlaveConnection) AddTransactions

func (s *SlaveConnection) AddTransactions(request *p2p.NewTransactionList) (*rpc.HashList, error)

func (*SlaveConnection) EstimateGas

func (s *SlaveConnection) EstimateGas(tx *types.Transaction, fromAddress *account.Address) (uint32, error)

func (*SlaveConnection) ExecuteTransaction

func (s *SlaveConnection) ExecuteTransaction(tx *types.Transaction, fromAddress *account.Address, height *uint64) ([]byte, error)

func (*SlaveConnection) GasPrice

func (s *SlaveConnection) GasPrice(branch account.Branch) (uint64, error)

func (*SlaveConnection) GenTx

func (s *SlaveConnection) GenTx(numTxPerShard, xShardPercent uint32, tx *types.Transaction) error

func (*SlaveConnection) GetAccountData

func (s *SlaveConnection) GetAccountData(address *account.Address, height *uint64) (*rpc.GetAccountDataResponse, error)

func (*SlaveConnection) GetCode

func (s *SlaveConnection) GetCode(address *account.Address, height *uint64) ([]byte, error)

func (*SlaveConnection) GetLogs

func (s *SlaveConnection) GetLogs(branch account.Branch, address []account.Address, topics [][]common.Hash, startBlock, endBlock uint64) ([]*types.Log, error)

func (*SlaveConnection) GetMinorBlockByHash

func (s *SlaveConnection) GetMinorBlockByHash(blockHash common.Hash, branch account.Branch) (*types.MinorBlock, error)

func (*SlaveConnection) GetMinorBlockByHeight

func (s *SlaveConnection) GetMinorBlockByHeight(height uint64, branch account.Branch) (*types.MinorBlock, error)

func (*SlaveConnection) GetMinorBlockHeaders

func (*SlaveConnection) GetMinorBlocks

func (*SlaveConnection) GetShardMaskList

func (s *SlaveConnection) GetShardMaskList() []*types.ChainMask

func (*SlaveConnection) GetSlaveID

func (s *SlaveConnection) GetSlaveID() string

func (*SlaveConnection) GetStorageAt

func (s *SlaveConnection) GetStorageAt(address *account.Address, key common.Hash, height *uint64) (common.Hash, error)

func (*SlaveConnection) GetTransactionByHash

func (s *SlaveConnection) GetTransactionByHash(txHash common.Hash, branch account.Branch) (*types.MinorBlock, uint32, error)

func (*SlaveConnection) GetTransactionReceipt

func (s *SlaveConnection) GetTransactionReceipt(txHash common.Hash, branch account.Branch) (*types.MinorBlock, uint32, *types.Receipt, error)

func (*SlaveConnection) GetTransactionsByAddress

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

func (*SlaveConnection) GetUnconfirmedHeaders

func (s *SlaveConnection) GetUnconfirmedHeaders() (*rpc.GetUnconfirmedHeadersResponse, error)

func (*SlaveConnection) GetWork

func (s *SlaveConnection) GetWork(branch account.Branch) (*consensus.MiningWork, error)

func (*SlaveConnection) HandleNewMinorBlock

func (s *SlaveConnection) HandleNewMinorBlock(request *p2p.NewBlockMinor) (bool, error)

func (*SlaveConnection) HandleNewTip

func (s *SlaveConnection) HandleNewTip(request *rpc.HandleNewTipRequest) (bool, error)

func (*SlaveConnection) HasShard

func (s *SlaveConnection) HasShard(fullShardID uint32) bool

func (*SlaveConnection) HeartBeat

func (s *SlaveConnection) HeartBeat() bool

func (*SlaveConnection) MasterInfo

func (s *SlaveConnection) MasterInfo(ip string, port uint16, rootTip *types.RootBlock) error

func (*SlaveConnection) SendConnectToSlaves

func (s *SlaveConnection) SendConnectToSlaves(slaveInfoLst []*rpc.SlaveInfo) error

func (*SlaveConnection) SendMiningConfigToSlaves

func (s *SlaveConnection) SendMiningConfigToSlaves(artificialTxConfig *rpc.ArtificialTxConfig, mining bool) error

func (*SlaveConnection) SendPing

func (s *SlaveConnection) SendPing() ([]byte, []*types.ChainMask, error)

func (*SlaveConnection) SetMining

func (s *SlaveConnection) SetMining(mining bool) error

func (*SlaveConnection) SubmitWork

func (s *SlaveConnection) SubmitWork(work *rpc.SubmitWorkRequest) (success bool, err error)

type TxForQueue

type TxForQueue struct {
	Time          uint64
	TxCount       uint32
	XShardTxCount uint32
}

Jump to

Keyboard shortcuts

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