Documentation
¶
Index ¶
- Constants
- Variables
- func InitBlockBlackCache(dataDir string) *invalidBlockCache
- func NewPeerSet(discover *p2p.DiscoverManager, dm *deputynode.Manager) *peerSet
- func VerifyLemoAddress(lemoAddress string) bool
- func VerifyNode(node string) error
- type BlockCache
- func (c *BlockCache) Add(block *types.Block)
- func (c *BlockCache) Clear(height uint32)
- func (c *BlockCache) FirstHeight() uint32
- func (c *BlockCache) IsExit(hash common.Hash, height uint32) bool
- func (c *BlockCache) Iterate(callback func(*types.Block) bool)
- func (c *BlockCache) Remove(block *types.Block)
- func (c *BlockCache) Size() int
- type BlockChain
- type BlockConfirmData
- type BlockConfirms
- type BlockHashData
- type ConfirmCache
- type DiscoverReqData
- type DiscoverResData
- type GetBlocksData
- type GetConfirmInfo
- type GetLatestStatus
- type GetSingleBlockData
- type HashSet
- type LatestStatus
- type MsgCache
- type ProtocolHandshake
- type ProtocolManager
- type TxPool
Constants ¶
View Source
const ( DurShort = 3 * time.Second DurLong = 10 * time.Second )
View Source
const BlackBlockFile = "blackblocklist"
区块黑名单cache
Variables ¶
View Source
var ( ErrInvalidCode = errors.New("invalid code about net message") ErrReadTimeout = errors.New("protocol handshake timeout") ErrReadMsg = errors.New("protocol handshake failed: read remote message failed") )
View Source
var ( ErrNodeInvalid = errors.New("discover node is invalid") ErrRequestBlocks = errors.New("invalid request blocks' param") ErrHandleLstStatusMsg = errors.New("stable height can't > current height") ErrHandleGetBlocksMsg = errors.New("invalid request blocks'param") )
View Source
var (
ErrInvalidNodeUri = errors.New("invalid node uri")
)
Functions ¶
func InitBlockBlackCache ¶ added in v1.4.0
func InitBlockBlackCache(dataDir string) *invalidBlockCache
func NewPeerSet ¶
func NewPeerSet(discover *p2p.DiscoverManager, dm *deputynode.Manager) *peerSet
NewPeerSet
func VerifyLemoAddress ¶ added in v1.3.0
VerifyLemoAddress check lemoAddress
func VerifyNode ¶ added in v1.3.0
VerifyNode check string node (node = nodeID@IP:Port)
Types ¶
type BlockCache ¶
type BlockCache struct {
// contains filtered or unexported fields
}
func NewBlockCache ¶
func NewBlockCache() *BlockCache
func (*BlockCache) Add ¶
func (c *BlockCache) Add(block *types.Block)
func (*BlockCache) Clear ¶
func (c *BlockCache) Clear(height uint32)
Clear clear blocks of block'Height <= height
func (*BlockCache) FirstHeight ¶
func (c *BlockCache) FirstHeight() uint32
func (*BlockCache) IsExit ¶ added in v1.3.0
func (c *BlockCache) IsExit(hash common.Hash, height uint32) bool
IsExit
func (*BlockCache) Remove ¶ added in v1.3.0
func (c *BlockCache) Remove(block *types.Block)
Remove remove a block
func (*BlockCache) Size ¶
func (c *BlockCache) Size() int
type BlockChain ¶
type BlockChain interface {
Genesis() *types.Block
// HasBlock if block exist in local chain
HasBlock(hash common.Hash) bool
// GetBlockByHeight get block by height from local chain
GetBlockByHeight(height uint32) *types.Block
// GetBlockByHash get block by hash from local chain
GetBlockByHash(hash common.Hash) *types.Block
// CurrentBlock local chain's current block
CurrentBlock() *types.Block
// StableBlock local chain's latest stable block
StableBlock() *types.Block
// InsertBlock insert a block to local chain. Return error for distribution project
InsertBlock(block *types.Block) error
// InsertConfirms received a block's confirm info
InsertConfirms(height uint32, blockHash common.Hash, sigList []types.SignData)
// IsInBlackList
IsInBlackList(b *types.Block) bool
}
BlockChain
type BlockConfirmData ¶
type BlockConfirmData struct {
Hash common.Hash // block Hash
Height uint32 // block height
SignInfo types.SignData // block sign info
}
blockConfirmData
type BlockConfirms ¶
type BlockConfirms struct {
Height uint32 // block height
Hash common.Hash // block hash
Pack []types.SignData
}
BlockConfirms confirms of a block
type ConfirmCache ¶
type ConfirmCache struct {
// contains filtered or unexported fields
}
ConfirmCache record block confirm data which block doesn't exist in local
func NewConfirmCache ¶
func NewConfirmCache() *ConfirmCache
func (*ConfirmCache) Clear ¶
func (c *ConfirmCache) Clear(height uint32)
Clear clear dirty data form cache
func (*ConfirmCache) Pop ¶
func (c *ConfirmCache) Pop(height uint32, hash common.Hash) []*BlockConfirmData
Pop get special confirm data by height and hash and then delete from cache
func (*ConfirmCache) Push ¶
func (c *ConfirmCache) Push(data *BlockConfirmData)
Push set block confirm data to cache
type GetLatestStatus ¶
type GetLatestStatus struct {
Revert uint32
}
GetLatestStatus get latest status
type GetSingleBlockData ¶
GetSingleBlockData
type LatestStatus ¶
type LatestStatus struct {
CurHeight uint32
CurHash common.Hash
StaHeight uint32
StaHash common.Hash
}
LatestStatus latest peer's status
type MsgCache ¶ added in v1.3.0
type MsgCache struct {
// contains filtered or unexported fields
}
func NewMsgCache ¶ added in v1.3.0
func NewMsgCache() *MsgCache
type ProtocolHandshake ¶
type ProtocolHandshake struct {
ChainID uint16
GenesisHash common.Hash
NodeVersion uint32
LatestStatus LatestStatus
}
ProtocolHandshake protocol handshake
func (*ProtocolHandshake) Bytes ¶
func (phs *ProtocolHandshake) Bytes() []byte
Bytes object to bytes
type ProtocolManager ¶
type ProtocolManager struct {
// contains filtered or unexported fields
}
func NewProtocolManager ¶
func NewProtocolManager(chainID uint16, nodeID p2p.NodeID, chain BlockChain, dm *deputynode.Manager, txPool TxPool, txGuard *txpool.TxGuard, discover *p2p.DiscoverManager, delayNodeLimit int, nodeVersion uint32, dataDir string) *ProtocolManager
type TxPool ¶
type TxPool interface {
/* 本节点出块时,从交易池中取出交易进行打包,但并不从交易池中删除 */
GetTxs(time uint32, size int) types.Transactions
/* 收到一笔新的交易 */
AddTx(tx *types.Transaction) error
}
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package p2p implements the Lemochain p2p network protocols.
|
Package p2p implements the Lemochain p2p network protocols. |
|
Package rpc provides access to the exported methods of an object across a network or other I/O connection.
|
Package rpc provides access to the exported methods of an object across a network or other I/O connection. |
Click to show internal directories.
Click to hide internal directories.