Help us shape the future of Go! Take the 2026 Go Developer Survey

blocksync

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2019 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvBlocksToPbBlocks

func ConvBlocksToPbBlocks(blocks []*coreTypes.Block) ([]*corepb.Block, error)

ConvBlocksToPbBlocks convert []*coreTypes.Block to []*corepb.Block

func ConvBytesArrayToHashes

func ConvBytesArrayToHashes(bytesArray [][]byte) ([]*crypto.HashType, error)

ConvBytesArrayToHashes convert [][]byte to []*crypto.HashType

func ConvHashesToBytesArray

func ConvHashesToBytesArray(hashes []*crypto.HashType) [][]byte

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

func ConvPbBlocksToBlocks(pbBlocks []*corepb.Block) ([]*coreTypes.Block, error)

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

type CheckHash struct {
	BeginHash *crypto.HashType
	Length    uint32
}

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

func (ch *CheckHash) FromProtoMessage(message proto.Message) error

FromProtoMessage converts proto message to CheckHash

func (*CheckHash) Marshal

func (ch *CheckHash) Marshal() (data []byte, err error)

Marshal method marshal CheckHash object to binary

func (*CheckHash) ToProtoMessage

func (ch *CheckHash) ToProtoMessage() (proto.Message, error)

ToProtoMessage converts CheckHash to proto message.

func (*CheckHash) Unmarshal

func (ch *CheckHash) Unmarshal(data []byte) error

Unmarshal method unmarshal binary data to CheckHash object

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

type LocateHeaders struct {
	Hashes []*crypto.HashType
}

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

type SyncCheckHash struct {
	RootHash *crypto.HashType
}

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) Run

func (sm *SyncManager) Run()

Run start sync task and handle sync message

func (*SyncManager) StartSync

func (sm *SyncManager) StartSync()

StartSync start sync block message from remote peers.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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