Documentation ¶
Index ¶
- func ConvBlocksToPbBlocks(blocks []*coreTypes.Block) ([]*corepb.Block, error)
- func ConvBytesArrayToHashes(bytesArray [][]byte) ([]*crypto.HashType, error)
- func ConvHashesToBytesArray(hashes []*crypto.HashType) [][]byte
- func ConvHeadersToPbHeaders(headers []*coreTypes.BlockHeader) ([]*corepb.BlockHeader, error)
- func ConvPbBlocksToBlocks(pbBlocks []*corepb.Block) ([]*coreTypes.Block, error)
- func ConvPbHeadersToHeaders(pbHeaders []*corepb.BlockHeader) ([]*coreTypes.BlockHeader, error)
- type CheckHash
- type FetchBlockHeaders
- type LocateHeaders
- type SyncBlocks
- type SyncCheckHash
- type SyncHeaders
- type SyncManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvBlocksToPbBlocks ¶
ConvBlocksToPbBlocks convert []*coreTypes.Block to []*corepb.Block
func ConvBytesArrayToHashes ¶
ConvBytesArrayToHashes convert [][]byte to []*crypto.HashType
func ConvHashesToBytesArray ¶
ConvHashesToBytesArray convert []*crypto.HashType to [][]byte
func ConvHeadersToPbHeaders ¶
func ConvHeadersToPbHeaders(headers []*coreTypes.BlockHeader) ( []*corepb.BlockHeader, error)
ConvHeadersToPbHeaders convert []*coreTypes.BlockHeader to []*corepb.BlockHeader
func ConvPbBlocksToBlocks ¶
ConvPbBlocksToBlocks convert []*corepb.Block to []*coreTypes.Block
func ConvPbHeadersToHeaders ¶
func ConvPbHeadersToHeaders(pbHeaders []*corepb.BlockHeader) ( []*coreTypes.BlockHeader, error)
ConvPbHeadersToHeaders convert []*corepb.BlockHeader to []*coreTypes.BlockHeader
Types ¶
type CheckHash ¶
CheckHash defines information about synchronizing check hash with the peer's chain, it only needs to check Length headers. Remote peer will send a root hash from the corresponding Headers
func (*CheckHash) FromProtoMessage ¶
FromProtoMessage converts proto message to CheckHash
func (*CheckHash) ToProtoMessage ¶
ToProtoMessage converts CheckHash to proto message.
type FetchBlockHeaders ¶
type FetchBlockHeaders struct { // the index to indicate which hashes chunk in sync hashes // it is used to find out which hashes chunk needed to re-sync when // error happen in the sync with some remote peer Idx uint32 CheckHash }
FetchBlockHeaders includes headers sent to a sync peer to fetch blocks
func (*FetchBlockHeaders) FromProtoMessage ¶
func (fbh *FetchBlockHeaders) FromProtoMessage(message proto.Message) error
FromProtoMessage converts proto message to FetchBlockHeaders
func (*FetchBlockHeaders) Marshal ¶
func (fbh *FetchBlockHeaders) Marshal() (data []byte, err error)
Marshal method marshal FetchBlockHeaders object to binary
func (*FetchBlockHeaders) ToProtoMessage ¶
func (fbh *FetchBlockHeaders) ToProtoMessage() (proto.Message, error)
ToProtoMessage converts FetchBlockHeaders to proto message.
func (*FetchBlockHeaders) Unmarshal ¶
func (fbh *FetchBlockHeaders) Unmarshal(data []byte) error
Unmarshal method unmarshal binary data to FetchBlockHeaders object
type LocateHeaders ¶
LocateHeaders includes hashes sent to a peer to locate fork point in the peer's chain
func (*LocateHeaders) FromProtoMessage ¶
func (lh *LocateHeaders) FromProtoMessage(message proto.Message) error
FromProtoMessage converts proto message to LocateHeaders
func (*LocateHeaders) Marshal ¶
func (lh *LocateHeaders) Marshal() (data []byte, err error)
Marshal method marshal LocateHeaders object to binary
func (*LocateHeaders) ToProtoMessage ¶
func (lh *LocateHeaders) ToProtoMessage() (proto.Message, error)
ToProtoMessage converts LocateHeaders to proto message.
func (*LocateHeaders) Unmarshal ¶
func (lh *LocateHeaders) Unmarshal(data []byte) error
Unmarshal method unmarshal binary data to LocateHeaders object
type SyncBlocks ¶
type SyncBlocks struct { // the index to indicate which hashes chunk in sync hashes // it is used to find out which hashes chunk needed to re-sync when // error happen in the sync with some remote peer Idx uint32 Blocks []*coreTypes.Block }
SyncBlocks includes blocks sent from synchronized peer to local node
func (*SyncBlocks) FromProtoMessage ¶
func (sb *SyncBlocks) FromProtoMessage(message proto.Message) error
FromProtoMessage converts proto message to SyncBlocks
func (*SyncBlocks) Marshal ¶
func (sb *SyncBlocks) Marshal() (data []byte, err error)
Marshal method marshal SyncBlocks object to binary
func (*SyncBlocks) ToProtoMessage ¶
func (sb *SyncBlocks) ToProtoMessage() (proto.Message, error)
ToProtoMessage converts SyncBlocks to proto message.
func (*SyncBlocks) Unmarshal ¶
func (sb *SyncBlocks) Unmarshal(data []byte) error
Unmarshal method unmarshal binary data to SyncBlocks object
type SyncCheckHash ¶
SyncCheckHash defines information about root hash for check in sync scenario. the RootHash is the hash for headers that CheckHash indicate
func (*SyncCheckHash) FromProtoMessage ¶
func (sch *SyncCheckHash) FromProtoMessage(message proto.Message) error
FromProtoMessage converts proto message to SyncCheckHash
func (*SyncCheckHash) Marshal ¶
func (sch *SyncCheckHash) Marshal() (data []byte, err error)
Marshal method marshal SyncCheckHash object to binary
func (*SyncCheckHash) ToProtoMessage ¶
func (sch *SyncCheckHash) ToProtoMessage() (proto.Message, error)
ToProtoMessage converts SyncCheckHash to proto message.
func (*SyncCheckHash) Unmarshal ¶
func (sch *SyncCheckHash) Unmarshal(data []byte) error
Unmarshal method unmarshal binary data to SyncCheckHash object
type SyncHeaders ¶
type SyncHeaders struct {
LocateHeaders
}
SyncHeaders includes the hashes that local node needs to sync with the peer's chain. SyncHeaders may contain overlapped block hashes with local chain
func (*SyncHeaders) FromProtoMessage ¶
func (sh *SyncHeaders) FromProtoMessage(message proto.Message) error
FromProtoMessage converts proto message to SyncHeaders
func (*SyncHeaders) Marshal ¶
func (sh *SyncHeaders) Marshal() (data []byte, err error)
Marshal method marshal LocateHeaders object to binary
func (*SyncHeaders) ToProtoMessage ¶
func (sh *SyncHeaders) ToProtoMessage() (proto.Message, error)
ToProtoMessage converts SyncHeaders to proto message.
func (*SyncHeaders) Unmarshal ¶
func (sh *SyncHeaders) Unmarshal(data []byte) error
Unmarshal method unmarshal binary data to SyncHeaders object
type SyncManager ¶
type SyncManager struct {
// contains filtered or unexported fields
}
SyncManager syncs blocks with peers
func NewSyncManager ¶
func NewSyncManager(blockChain *chain.BlockChain, p2pNet p2p.Net, consensus *dpos.Dpos, parent goprocess.Process) *SyncManager
NewSyncManager returns new block sync manager.
func (*SyncManager) ActiveLightSync ¶
func (sm *SyncManager) ActiveLightSync(pid peer.ID) error
ActiveLightSync active light sync from remote peer.
func (*SyncManager) StartSync ¶
func (sm *SyncManager) StartSync()
StartSync start sync block message from remote peers.