p2p

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: 28 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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileDownloader

type FileDownloader struct {
	FileService                service.FileServiceInterface
	P2pService                 Peer2PeerServiceInterface
	BlockSpinePublicKeyService service.BlockSpinePublicKeyServiceInterface
	BlockchainStatusService    service.BlockchainStatusServiceInterface
	ChunkUtil                  util.ChunkUtilInterface
	Logger                     *log.Logger
}

func NewFileDownloader

func NewFileDownloader(
	p2pService Peer2PeerServiceInterface,
	fileService service.FileServiceInterface,
	blockchainStatusService service.BlockchainStatusServiceInterface,
	blockSpinePublicKeyService service.BlockSpinePublicKeyServiceInterface,
	chunkUtil util.ChunkUtilInterface,
	logger *log.Logger,
) *FileDownloader

func (*FileDownloader) DownloadSnapshot

func (ss *FileDownloader) DownloadSnapshot(
	ct chaintype.ChainType,
	spineBlockManifest *model.SpineBlockManifest,
) (*model.SnapshotFileInfo, error)

DownloadSnapshot downloads a snapshot from the p2p network

type FileDownloaderInterface

type FileDownloaderInterface interface {
	DownloadSnapshot(ct chaintype.ChainType, spineBlockManifest *model.SpineBlockManifest) (*model.SnapshotFileInfo, error)
}

FileDownloaderInterface snapshot logic shared across block types

type Peer2PeerService

type Peer2PeerService struct {
	PeerExplorer             strategy.PeerExplorerStrategyInterface
	PeerServiceClient        client.PeerServiceClientInterface
	Logger                   *log.Logger
	TransactionUtil          transaction.UtilInterface
	FileService              coreService.FileServiceInterface
	NodeRegistrationService  coreService.NodeRegistrationServiceInterface
	NodeConfigurationService coreService.NodeConfigurationServiceInterface
	FeedbackStrategy         feedbacksystem.FeedbackStrategyInterface
}

func (*Peer2PeerService) DownloadFilesFromPeer

func (s *Peer2PeerService) DownloadFilesFromPeer(
	snapshotHash []byte,
	fileChunksNames []string,
	validNodeIDs map[int64]bool,
	maxRetryCount uint32,
) ([]string, error)

DownloadFilesFromPeer download a file from a random peer

func (*Peer2PeerService) GetHostInfo

func (s *Peer2PeerService) GetHostInfo() *model.Host

GetHostInfo exposed the p2p host information to the client

func (*Peer2PeerService) GetPriorityPeers

func (s *Peer2PeerService) GetPriorityPeers() map[string]*model.Peer

GetPriorityPeers exposed current node priority peer list.

func (*Peer2PeerService) GetResolvedPeers

func (s *Peer2PeerService) GetResolvedPeers() map[string]*model.Peer

GetResolvedPeers exposed current node resolved peer list

func (*Peer2PeerService) GetUnresolvedPeers

func (s *Peer2PeerService) GetUnresolvedPeers() map[string]*model.Peer

GetUnresolvedPeers exposed current node unresolved peer list.

func (*Peer2PeerService) RequestBlockTransactionsListener

func (s *Peer2PeerService) RequestBlockTransactionsListener() observer.Listener

func (*Peer2PeerService) SendBlockListener

func (s *Peer2PeerService) SendBlockListener() observer.Listener

SendBlockListener setup listener for send block to the list peer

func (*Peer2PeerService) SendBlockTransactionsListener

func (s *Peer2PeerService) SendBlockTransactionsListener() observer.Listener

func (*Peer2PeerService) SendTransactionListener

func (s *Peer2PeerService) SendTransactionListener() observer.Listener

SendTransactionListener setup listener for transaction to the list peer

func (*Peer2PeerService) StartP2P

func (s *Peer2PeerService) StartP2P(
	myAddress string,
	ownerAccountAddress []byte,
	peerPort uint32,
	nodeSecretPhrase string,
	queryExecutor query.ExecutorInterface,
	blockServices map[int32]coreService.BlockServiceInterface,
	mempoolServices map[int32]coreService.MempoolServiceInterface,
	fileService coreService.FileServiceInterface,
	nodeRegistrationService coreService.NodeRegistrationServiceInterface,
	nodeConfigurationService coreService.NodeConfigurationServiceInterface,
	nodeAddressInfoService coreService.NodeAddressInfoServiceInterface,
	observer *observer.Observer,
	feedbackStrategy feedbacksystem.FeedbackStrategyInterface,
	scrambleNodeCache storage.CacheStackStorageInterface,
)

StartP2P initiate all p2p dependencies and run all p2p thread service

type Peer2PeerServiceInterface

type Peer2PeerServiceInterface interface {
	StartP2P(
		myAddress string,
		ownerAccountAddress []byte,
		peerPort uint32,
		nodeSecretPhrase string,
		queryExecutor query.ExecutorInterface,
		blockServices map[int32]coreService.BlockServiceInterface,
		mempoolServices map[int32]coreService.MempoolServiceInterface,
		fileService coreService.FileServiceInterface,
		nodeRegistrationService coreService.NodeRegistrationServiceInterface,
		nodeConfigurationService coreService.NodeConfigurationServiceInterface,
		nodeAddressInfoService coreService.NodeAddressInfoServiceInterface,
		observer *observer.Observer,
		feedbackStrategy feedbacksystem.FeedbackStrategyInterface,
		scrambleNodeCache storage.CacheStackStorageInterface,
	)
	// exposed api list
	GetHostInfo() *model.Host
	GetResolvedPeers() map[string]*model.Peer
	GetUnresolvedPeers() map[string]*model.Peer
	GetPriorityPeers() map[string]*model.Peer

	// event listener that relate to p2p communication
	SendBlockListener() observer.Listener
	SendTransactionListener() observer.Listener
	RequestBlockTransactionsListener() observer.Listener
	SendBlockTransactionsListener() observer.Listener
	DownloadFilesFromPeer(
		fullHash []byte,
		fileChunksNames []string,
		validNodeIDs map[int64]bool,
		retryCount uint32,
	) (failed []string, err error)
}

func NewP2PService

NewP2PService to initialize peer to peer service wrapper

Directories

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

Jump to

Keyboard shortcuts

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