blockchainsync

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2021 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

ZooBC Copyright (C) 2020 Quasisoft Limited - Hong Kong This file is part of ZooBC <https://github.com/zoobc/zoobc-core>

ZooBC is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

ZooBC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with ZooBC. If not, see <http://www.gnu.org/licenses/>.

Additional Permission Under GNU GPL Version 3 section 7. As the special exception permitted under Section 7b, c and e, in respect with the Author’s copyright, please refer to this section:

  1. You are free to convey this Program according to GNU GPL Version 3, as long as you respect and comply with the Author’s copyright by showing in its user interface an Appropriate Notice that the derivate program and its source code are “powered by ZooBC”. This is an acknowledgement for the copyright holder, ZooBC, as the implementation of appreciation of the exclusive right of the creator and to avoid any circumvention on the rights under trademark law for use of some trade names, trademarks, or service marks.
  1. Complying to the GNU GPL Version 3, you may distribute the program without any permission from the Author. However a prior notification to the authors will be appreciated.

ZooBC is architected by Roberto Capodieci & Barton Johnston

contact us at roberto.capodieci[at]blockchainzoo.com
and barton.johnston[at]blockchainzoo.com

Core developers that contributed to the current implementation of the software are:

Ahmad Ali Abdilah ahmad.abdilah[at]blockchainzoo.com
Allan Bintoro allan.bintoro[at]blockchainzoo.com
Andy Herman
Gede Sukra
Ketut Ariasa
Nawi Kartini nawi.kartini[at]blockchainzoo.com
Stefano Galassi stefano.galassi[at]blockchainzoo.com

IMPORTANT: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

ZooBC Copyright (C) 2020 Quasisoft Limited - Hong Kong This file is part of ZooBC <https://github.com/zoobc/zoobc-core>

ZooBC is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

ZooBC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with ZooBC. If not, see <http://www.gnu.org/licenses/>.

Additional Permission Under GNU GPL Version 3 section 7. As the special exception permitted under Section 7b, c and e, in respect with the Author’s copyright, please refer to this section:

  1. You are free to convey this Program according to GNU GPL Version 3, as long as you respect and comply with the Author’s copyright by showing in its user interface an Appropriate Notice that the derivate program and its source code are “powered by ZooBC”. This is an acknowledgement for the copyright holder, ZooBC, as the implementation of appreciation of the exclusive right of the creator and to avoid any circumvention on the rights under trademark law for use of some trade names, trademarks, or service marks.
  1. Complying to the GNU GPL Version 3, you may distribute the program without any permission from the Author. However a prior notification to the authors will be appreciated.

ZooBC is architected by Roberto Capodieci & Barton Johnston

contact us at roberto.capodieci[at]blockchainzoo.com
and barton.johnston[at]blockchainzoo.com

Core developers that contributed to the current implementation of the software are:

Ahmad Ali Abdilah ahmad.abdilah[at]blockchainzoo.com
Allan Bintoro allan.bintoro[at]blockchainzoo.com
Andy Herman
Gede Sukra
Ketut Ariasa
Nawi Kartini nawi.kartini[at]blockchainzoo.com
Stefano Galassi stefano.galassi[at]blockchainzoo.com

IMPORTANT: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

ZooBC Copyright (C) 2020 Quasisoft Limited - Hong Kong This file is part of ZooBC <https://github.com/zoobc/zoobc-core>

ZooBC is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

ZooBC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with ZooBC. If not, see <http://www.gnu.org/licenses/>.

Additional Permission Under GNU GPL Version 3 section 7. As the special exception permitted under Section 7b, c and e, in respect with the Author’s copyright, please refer to this section:

  1. You are free to convey this Program according to GNU GPL Version 3, as long as you respect and comply with the Author’s copyright by showing in its user interface an Appropriate Notice that the derivate program and its source code are “powered by ZooBC”. This is an acknowledgement for the copyright holder, ZooBC, as the implementation of appreciation of the exclusive right of the creator and to avoid any circumvention on the rights under trademark law for use of some trade names, trademarks, or service marks.
  1. Complying to the GNU GPL Version 3, you may distribute the program without any permission from the Author. However a prior notification to the authors will be appreciated.

ZooBC is architected by Roberto Capodieci & Barton Johnston

contact us at roberto.capodieci[at]blockchainzoo.com
and barton.johnston[at]blockchainzoo.com

Core developers that contributed to the current implementation of the software are:

Ahmad Ali Abdilah ahmad.abdilah[at]blockchainzoo.com
Allan Bintoro allan.bintoro[at]blockchainzoo.com
Andy Herman
Gede Sukra
Ketut Ariasa
Nawi Kartini nawi.kartini[at]blockchainzoo.com
Stefano Galassi stefano.galassi[at]blockchainzoo.com

IMPORTANT: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

ZooBC Copyright (C) 2020 Quasisoft Limited - Hong Kong This file is part of ZooBC <https://github.com/zoobc/zoobc-core>

ZooBC is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

ZooBC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with ZooBC. If not, see <http://www.gnu.org/licenses/>.

Additional Permission Under GNU GPL Version 3 section 7. As the special exception permitted under Section 7b, c and e, in respect with the Author’s copyright, please refer to this section:

  1. You are free to convey this Program according to GNU GPL Version 3, as long as you respect and comply with the Author’s copyright by showing in its user interface an Appropriate Notice that the derivate program and its source code are “powered by ZooBC”. This is an acknowledgement for the copyright holder, ZooBC, as the implementation of appreciation of the exclusive right of the creator and to avoid any circumvention on the rights under trademark law for use of some trade names, trademarks, or service marks.
  1. Complying to the GNU GPL Version 3, you may distribute the program without any permission from the Author. However a prior notification to the authors will be appreciated.

ZooBC is architected by Roberto Capodieci & Barton Johnston

contact us at roberto.capodieci[at]blockchainzoo.com
and barton.johnston[at]blockchainzoo.com

Core developers that contributed to the current implementation of the software are:

Ahmad Ali Abdilah ahmad.abdilah[at]blockchainzoo.com
Allan Bintoro allan.bintoro[at]blockchainzoo.com
Andy Herman
Gede Sukra
Ketut Ariasa
Nawi Kartini nawi.kartini[at]blockchainzoo.com
Stefano Galassi stefano.galassi[at]blockchainzoo.com

IMPORTANT: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockchainDownloadInterface

type BlockchainDownloadInterface interface {
	IsDownloadFinish(currentLastBlock *model.Block) bool
	GetPeerBlockchainInfo() (*PeerBlockchainInfo, error)
	DownloadFromPeer(feederPeer *model.Peer, chainBlockIds []int64, commonBlock *model.Block) (*PeerForkInfo, error)
	ConfirmWithPeer(peerToCheck *model.Peer, commonMilestoneBlockID int64) ([]int64, error)
}

type BlockchainDownloader

type BlockchainDownloader struct {
	PeerHasMore             bool
	ChainType               chaintype.ChainType
	BlockService            service.BlockServiceInterface
	PeerServiceClient       client.PeerServiceClientInterface
	PeerExplorer            strategy.PeerExplorerStrategyInterface
	Logger                  *log.Logger
	BlockchainStatusService service.BlockchainStatusServiceInterface
	// contains filtered or unexported fields
}

func NewBlockchainDownloader

func NewBlockchainDownloader(
	blockService service.BlockServiceInterface,
	peerServiceClient client.PeerServiceClientInterface,
	peerExplorer strategy.PeerExplorerStrategyInterface,
	logger *log.Logger,
	blockchainStatusService service.BlockchainStatusServiceInterface,
) *BlockchainDownloader

func (*BlockchainDownloader) ConfirmWithPeer

func (bd *BlockchainDownloader) ConfirmWithPeer(peerToCheck *model.Peer, commonMilestoneBlockID int64) ([]int64, error)

ConfirmWithPeer confirms the state of our blockchain with other peer returns (otherPeerChainBlockIds: []int64, error) if otherPeerChainBlockIds has member, it means that there are blocks to download from the peer

func (*BlockchainDownloader) DownloadFromPeer

func (bd *BlockchainDownloader) DownloadFromPeer(feederPeer *model.Peer, chainBlockIds []int64,
	commonBlock *model.Block) (*PeerForkInfo, error)

func (*BlockchainDownloader) GetPeerBlockchainInfo

func (bd *BlockchainDownloader) GetPeerBlockchainInfo() (*PeerBlockchainInfo, error)

func (*BlockchainDownloader) IsDownloadFinish

func (bd *BlockchainDownloader) IsDownloadFinish(currentLastBlock *model.Block) bool

type BlockchainOrchestratorService

type BlockchainOrchestratorService struct {
	SpinechainSyncService          BlockchainSyncServiceInterface
	MainchainSyncService           BlockchainSyncServiceInterface
	BlockchainStatusService        service.BlockchainStatusServiceInterface
	SpineBlockManifestService      service.SpineBlockManifestServiceInterface
	FileDownloader                 p2p.FileDownloaderInterface
	MainchainSnapshotBlockServices service.SnapshotBlockServiceInterface
	Logger                         *log.Logger
}

func NewBlockchainOrchestratorService

func NewBlockchainOrchestratorService(
	spinechainSyncService, mainchainSyncService BlockchainSyncServiceInterface,
	blockchainStatusService service.BlockchainStatusServiceInterface,
	spineBlockManifestService service.SpineBlockManifestServiceInterface,
	fileDownloader p2p.FileDownloaderInterface,
	mainchainSnapshotBlockServices service.SnapshotBlockServiceInterface,
	logger *log.Logger) *BlockchainOrchestratorService

NewBlockchainOrchestratorService returns service instance for orchestrating the blockchains as multiple blockhains are implemented in the application, this service controls the behavior of the blockchains so that the expected behavior is consistent within the application. In the future, this service may also be expanded to orchestrate the smithing activity of the blockchains

func (*BlockchainOrchestratorService) DownloadSnapshot

func (bos *BlockchainOrchestratorService) DownloadSnapshot(ct chaintype.ChainType) error

func (*BlockchainOrchestratorService) Start

func (bos *BlockchainOrchestratorService) Start() error

func (*BlockchainOrchestratorService) StartSyncChain

func (bos *BlockchainOrchestratorService) StartSyncChain(chainSyncService BlockchainSyncServiceInterface, timeout time.Duration) error

type BlockchainSyncService

type BlockchainSyncService struct {
	ChainType               chaintype.ChainType
	PeerServiceClient       client.PeerServiceClientInterface
	PeerExplorer            strategy.PeerExplorerStrategyInterface
	BlockService            service.BlockServiceInterface
	BlockchainDownloader    BlockchainDownloadInterface
	ForkingProcessor        ForkingProcessorInterface
	Logger                  *log.Logger
	TransactionUtil         transaction.UtilInterface
	BlockchainStatusService service.BlockchainStatusServiceInterface
}

TODO: rename into something more specific, such as SyncService

func NewBlockchainSyncService

func NewBlockchainSyncService(
	blockService service.BlockServiceInterface,
	peerServiceClient client.PeerServiceClientInterface,
	peerExplorer strategy.PeerExplorerStrategyInterface,
	logger *log.Logger,
	blockchainStatusService service.BlockchainStatusServiceInterface,
	blockchainDownloader BlockchainDownloadInterface,
	forkingProcessor ForkingProcessorInterface,
) *BlockchainSyncService

func (*BlockchainSyncService) GetBlockService

func (bss *BlockchainSyncService) GetBlockService() service.BlockServiceInterface

func (*BlockchainSyncService) GetMoreBlocksThread

func (bss *BlockchainSyncService) GetMoreBlocksThread()

func (*BlockchainSyncService) Start

func (bss *BlockchainSyncService) Start()

type BlockchainSyncServiceInterface

type BlockchainSyncServiceInterface interface {
	GetBlockService() service.BlockServiceInterface
	Start()
}

TODO: rename into something more specific, such as SyncService

type ForkingProcessor

type ForkingProcessor struct {
	ChainType             chaintype.ChainType
	BlockService          service.BlockServiceInterface
	QueryExecutor         query.ExecutorInterface
	ActionTypeSwitcher    transaction.TypeActionSwitcher
	MempoolService        service.MempoolServiceInterface
	Logger                *log.Logger
	PeerExplorer          strategy.PeerExplorerStrategyInterface
	TransactionUtil       transaction.UtilInterface
	TransactionCorService service.TransactionCoreServiceInterface
	MempoolBackupStorage  storage.CacheStorageInterface
}

func (*ForkingProcessor) ProcessFork

func (fp *ForkingProcessor) ProcessFork(forkBlocks []*model.Block, commonBlock *model.Block, feederPeer *model.Peer) error

ProcessFork processes the forked blocks

func (*ForkingProcessor) ProcessLater

func (fp *ForkingProcessor) ProcessLater(txs []*model.Transaction) error

func (*ForkingProcessor) ScheduleScan

func (fp *ForkingProcessor) ScheduleScan(height uint32, validate bool)

type ForkingProcessorInterface

type ForkingProcessorInterface interface {
	ProcessFork(forkBlocks []*model.Block, commonBlock *model.Block, feederPeer *model.Peer) error
}

type PeerBlockchainInfo

type PeerBlockchainInfo struct {
	Peer                   *model.Peer
	ChainBlockIds          []int64
	CommonBlock            *model.Block
	CommonMilestoneBlockID int64
}

type PeerForkInfo

type PeerForkInfo struct {
	ForkBlocks []*model.Block
	FeederPeer *model.Peer
}

Jump to

Keyboard shortcuts

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