strategy

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 NativeStrategy

type NativeStrategy struct {
	Host                 *model.Host
	PeerServiceClient    client.PeerServiceClientInterface
	ResolvedPeersLock    sync.RWMutex
	UnresolvedPeersLock  sync.RWMutex
	BlacklistedPeersLock sync.RWMutex
	MaxUnresolvedPeers   int32
	MaxResolvedPeers     int32
	Logger               *log.Logger
}

NativeStrategy represent data service node as server

func NewNativeStrategy

func NewNativeStrategy(
	host *model.Host,
	peerServiceClient client.PeerServiceClientInterface,
	logger *log.Logger,
) *NativeStrategy

func (*NativeStrategy) AddToBlacklistPeer

func (ns *NativeStrategy) AddToBlacklistPeer(peer *model.Peer) error

AddToBlacklistPeer to add a peer into resolved peer

func (*NativeStrategy) AddToResolvedPeer

func (ns *NativeStrategy) AddToResolvedPeer(peer *model.Peer) error

AddToResolvedPeer to add a peer into resolved peer

func (*NativeStrategy) AddToUnresolvedPeer

func (ns *NativeStrategy) AddToUnresolvedPeer(peer *model.Peer) error

AddToUnresolvedPeer to add a peer into unresolved peer

func (*NativeStrategy) AddToUnresolvedPeers

func (ns *NativeStrategy) AddToUnresolvedPeers(newNodes []*model.Node, toForce bool) error

AddToUnresolvedPeers to add incoming peers to UnresolvedPeers list toForce: if it's true, when the unresolvedPeers list is full, we will kick another one inside

(by choosing 1 random node)

func (*NativeStrategy) DisconnectPeer

func (ns *NativeStrategy) DisconnectPeer(peer *model.Peer)

DisconnectPeer moves connected peer to resolved peer if the unresolved peer is full (maybe) it should not go to the unresolved peer

func (*NativeStrategy) GenerateProofOfOrigin

func (ns *NativeStrategy) GenerateProofOfOrigin(
	challenge []byte,
	timestamp int64,
	nodeSecretPhrase string,
) *model.ProofOfOrigin

TODO implement this method GenerateProofOfOrigin generate a proof of origin message from a challenge request and sign it

func (*NativeStrategy) GetAnyKnownPeer

func (ns *NativeStrategy) GetAnyKnownPeer() *model.Peer

GetAnyKnownPeer Get any known peer

func (*NativeStrategy) GetAnyResolvedPeer

func (ns *NativeStrategy) GetAnyResolvedPeer() *model.Peer

GetAnyResolvedPeer Get any random resolved peer

func (*NativeStrategy) GetAnyUnresolvedPeer

func (ns *NativeStrategy) GetAnyUnresolvedPeer() *model.Peer

GetAnyUnresolvedPeer Get any unresolved peer

func (*NativeStrategy) GetBlacklistedPeers

func (ns *NativeStrategy) GetBlacklistedPeers() map[string]*model.Peer

GetBlacklistedPeers returns resolved peers in thread-safe manner

func (*NativeStrategy) GetExceedMaxResolvedPeers

func (ns *NativeStrategy) GetExceedMaxResolvedPeers() int32

GetExceedMaxResolvedPeers returns number of peers exceeding max number of the resolved peers

func (*NativeStrategy) GetExceedMaxUnresolvedPeers

func (ns *NativeStrategy) GetExceedMaxUnresolvedPeers() int32

GetExceedMaxUnresolvedPeers returns number of peers exceeding max number of the unresolved peers

func (*NativeStrategy) GetHostInfo

func (ns *NativeStrategy) GetHostInfo() *model.Node

func (*NativeStrategy) GetMorePeersHandler

func (ns *NativeStrategy) GetMorePeersHandler() (*model.Peer, error)

GetMorePeersHandler request peers to random peer in list and if get new peers will add to unresolved peer

func (*NativeStrategy) GetMorePeersThread

func (ns *NativeStrategy) GetMorePeersThread()

GetMorePeersThread to periodically request more peers from another node in Peers list

func (*NativeStrategy) GetPriorityPeers

func (ns *NativeStrategy) GetPriorityPeers() map[string]*model.Peer

GetPriorityPeers returns resolved peers in thread-safe manner

func (*NativeStrategy) GetPriorityPeersByFullAddress

func (ns *NativeStrategy) GetPriorityPeersByFullAddress(priorityPeers map[string]*model.Peer) map[string]*model.Peer

func (*NativeStrategy) GetResolvedPeers

func (ns *NativeStrategy) GetResolvedPeers() map[string]*model.Peer

GetResolvedPeers returns resolved peers in thread-safe manner

func (*NativeStrategy) GetUnresolvedPeers

func (ns *NativeStrategy) GetUnresolvedPeers() map[string]*model.Peer

GetUnresolvedPeers returns unresolved peers in thread-safe manner

func (*NativeStrategy) PeerBlacklist

func (ns *NativeStrategy) PeerBlacklist(peer *model.Peer, cause string) error

PeerBlacklist process to add blacklisted peer

func (*NativeStrategy) PeerUnblacklist

func (ns *NativeStrategy) PeerUnblacklist(peer *model.Peer) *model.Peer

PeerUnblacklist to update Peer state of peer

func (*NativeStrategy) ReceiveNodeAddressInfo

func (ns *NativeStrategy) ReceiveNodeAddressInfo(nodeAddressInfo *model.NodeAddressInfo) error

TODO implement this method ReceiveNodeAddressInfo receive a node address info from a peer (server side of SendNodeAddressInfo client api call)

func (*NativeStrategy) RemoveBlacklistedPeer

func (ns *NativeStrategy) RemoveBlacklistedPeer(peer *model.Peer) error

RemoveBlacklistedPeer removes peer from Blacklisted peer list

func (*NativeStrategy) RemoveResolvedPeer

func (ns *NativeStrategy) RemoveResolvedPeer(peer *model.Peer) error

RemoveResolvedPeer removes peer from Resolved peer list

func (*NativeStrategy) RemoveUnresolvedPeer

func (ns *NativeStrategy) RemoveUnresolvedPeer(peer *model.Peer) error

RemoveUnresolvedPeer removes peer from unresolved peer list

func (*NativeStrategy) ResolvePeers

func (ns *NativeStrategy) ResolvePeers()

ResolvePeers looping unresolved peers and adding to (resolve) Peers if get response

func (*NativeStrategy) ResolvePeersThread

func (ns *NativeStrategy) ResolvePeersThread()

ResolvePeersThread to periodically try get response from peers in UnresolvedPeer list

func (*NativeStrategy) Start

func (ns *NativeStrategy) Start()

Start method to start threads which mean goroutines for NativeStrategy

func (*NativeStrategy) SyncNodeAddressInfoTable

func (ns *NativeStrategy) SyncNodeAddressInfoTable(nodeRegistrations []*model.NodeRegistration) (map[int64]*model.NodeAddressInfo, error)

TODO implement this method GetNodeAddressesInfo request a list of node addresses from peers

func (*NativeStrategy) UpdateBlacklistedStatusThread

func (ns *NativeStrategy) UpdateBlacklistedStatusThread()

UpdateBlacklistedStatusThread to periodically check blacklisting time of black listed peer, every 60sec if there are blacklisted peers to unblacklist

func (*NativeStrategy) UpdateOwnNodeAddressInfo

func (ns *NativeStrategy) UpdateOwnNodeAddressInfo(nodeAddress string, port uint32, nodeSecretPhrase string) error

TODO implement this method UpdateOwnNodeAddressInfo check if nodeAddress in db must be updated and broadcast the new address

func (*NativeStrategy) UpdateResolvedPeers

func (ns *NativeStrategy) UpdateResolvedPeers()

func (*NativeStrategy) ValidateRequest

func (ns *NativeStrategy) ValidateRequest(context.Context) bool

type PeerExplorerStrategyInterface

type PeerExplorerStrategyInterface interface {
	Start()
	GetHostInfo() *model.Node
	GetAnyResolvedPeer() *model.Peer
	GetMorePeersHandler() (*model.Peer, error)
	GetUnresolvedPeers() map[string]*model.Peer
	GetResolvedPeers() map[string]*model.Peer
	GetPriorityPeers() map[string]*model.Peer
	GetPriorityPeersByFullAddress(priorityPeers map[string]*model.Peer) (priorityPeersByAddr map[string]*model.Peer)
	AddToUnresolvedPeers(newNodes []*model.Node, toForce bool) error
	GetBlacklistedPeers() map[string]*model.Peer
	PeerBlacklist(peer *model.Peer, cause string) error
	DisconnectPeer(peer *model.Peer)
	PeerUnblacklist(peer *model.Peer) *model.Peer
	ValidateRequest(ctx context.Context) bool
	SyncNodeAddressInfoTable(nodeRegistrations []*model.NodeRegistration) (map[int64]*model.NodeAddressInfo, error)
	ReceiveNodeAddressInfo(nodeAddressInfo []*model.NodeAddressInfo) error
	UpdateOwnNodeAddressInfo(nodeAddress string, port uint32, forceBroadcast bool) error
	GenerateProofOfOrigin(challengeMessage []byte, timestamp int64, secretPhrase string) *model.ProofOfOrigin
	ValidatePriorityPeer(scrambledNodes *model.ScrambledNodes, host, peer *model.Node) bool
}

type PeerStrategyHelper

type PeerStrategyHelper struct {
}

PeerStrategyHelper helper functions shared by peer strategies

func NewPeerStrategyHelper

func NewPeerStrategyHelper() *PeerStrategyHelper

func (*PeerStrategyHelper) GetRandomPeerWithoutRepetition

func (ps *PeerStrategyHelper) GetRandomPeerWithoutRepetition(peers map[string]*model.Peer, mutex *sync.Mutex) *model.Peer

GetRandomPeerWithoutRepetition get a random peer from a list. the returned peer is removed from the list (peer parameter) so that, when the function is called again, the same peer wont' be selected. NOTE: this function is thread-safe and can be used with concurrent goroutines

type PeerStrategyHelperInterface

type PeerStrategyHelperInterface interface {
	GetRandomPeerWithoutRepetition(peers map[string]*model.Peer, mutex *sync.Mutex) *model.Peer
}

type PriorityStrategy

type PriorityStrategy struct {
	BlockchainStatusService  coreService.BlockchainStatusServiceInterface
	NodeConfigurationService coreService.NodeConfigurationServiceInterface
	PeerServiceClient        client.PeerServiceClientInterface
	NodeRegistrationService  coreService.NodeRegistrationServiceInterface
	NodeAddressInfoService   coreService.NodeAddressInfoServiceInterface
	BlockMainService         coreService.BlockServiceInterface
	ResolvedPeersLock        sync.RWMutex
	UnresolvedPeersLock      sync.RWMutex
	BlacklistedPeersLock     sync.RWMutex
	MaxUnresolvedPeers       int32
	MaxResolvedPeers         int32
	Logger                   *log.Logger
	PeerStrategyHelper       PeerStrategyHelperInterface
	Signature                crypto.SignatureInterface
	ScrambleNodeService      coreService.ScrambleNodeServiceInterface
	// PendingNodeAddresses map containing node full address -> timestamp of last time the node tried to connect to that address
	NodeAddressesLastTryConnect     map[string]int64
	NodeAddressesLastTryConnectLock sync.RWMutex
}

PriorityStrategy represent data service node as server

func NewPriorityStrategy

func NewPriorityStrategy(
	peerServiceClient client.PeerServiceClientInterface,
	nodeRegistrationService coreService.NodeRegistrationServiceInterface,
	nodeAddressInfoService coreService.NodeAddressInfoServiceInterface,
	blockMainService coreService.BlockServiceInterface,
	logger *log.Logger,
	peerStrategyHelper PeerStrategyHelperInterface,
	nodeConfigurationService coreService.NodeConfigurationServiceInterface,
	blockchainStatusService coreService.BlockchainStatusServiceInterface,
	signature crypto.SignatureInterface,
	scrambleNodeService coreService.ScrambleNodeServiceInterface,
) *PriorityStrategy

func (*PriorityStrategy) AddToBlacklistedPeer

func (ps *PriorityStrategy) AddToBlacklistedPeer(peer *model.Peer, cause string) error

AddToBlacklistedPeer to add a peer into blacklisted peer

func (*PriorityStrategy) AddToResolvedPeer

func (ps *PriorityStrategy) AddToResolvedPeer(peer *model.Peer) error

AddToResolvedPeer to add a peer into resolved peer

func (*PriorityStrategy) AddToUnresolvedPeer

func (ps *PriorityStrategy) AddToUnresolvedPeer(peer *model.Peer) error

AddToUnresolvedPeer to add a peer into unresolved peer

func (*PriorityStrategy) AddToUnresolvedPeers

func (ps *PriorityStrategy) AddToUnresolvedPeers(newNodes []*model.Node, toForce bool) error

AddToUnresolvedPeers to add incoming peers to UnresolvedPeers list toForce: this parameter is not used in the PriorityStrategy because

only priority nodes can forcefully get into peers list

func (*PriorityStrategy) ConnectPriorityPeersGradually

func (ps *PriorityStrategy) ConnectPriorityPeersGradually()

func (*PriorityStrategy) ConnectPriorityPeersThread

func (ps *PriorityStrategy) ConnectPriorityPeersThread()

func (*PriorityStrategy) DisconnectPeer

func (ps *PriorityStrategy) DisconnectPeer(peer *model.Peer)

DisconnectPeer moves connected peer to unresolved peer if the unresolved peer is full (maybe) it should not go to the unresolved peer

func (*PriorityStrategy) GenerateProofOfOrigin

func (ps *PriorityStrategy) GenerateProofOfOrigin(
	challenge []byte,
	timestamp int64,
	nodeSecretPhrase string,
) *model.ProofOfOrigin

GenerateProofOfOrigin generate a proof of origin message from a challenge request and sign it

func (*PriorityStrategy) GetAnyKnownPeer

func (ps *PriorityStrategy) GetAnyKnownPeer() *model.Peer

GetAnyKnownPeer Get any known peer

func (*PriorityStrategy) GetAnyResolvedPeer

func (ps *PriorityStrategy) GetAnyResolvedPeer() *model.Peer

GetAnyResolvedPeer Get any random resolved peer

func (*PriorityStrategy) GetAnyUnresolvedPeer

func (ps *PriorityStrategy) GetAnyUnresolvedPeer() *model.Peer

GetAnyUnresolvedPeer Get any unresolved peer

func (*PriorityStrategy) GetBlacklistedPeerByAddressPort

func (ps *PriorityStrategy) GetBlacklistedPeerByAddressPort(addressPort string) (peer *model.Peer)

GetBlacklistedPeerByAddressPort to get blacklisted peer by full address port peer

func (*PriorityStrategy) GetBlacklistedPeers

func (ps *PriorityStrategy) GetBlacklistedPeers() map[string]*model.Peer

GetBlacklistedPeers returns resolved peers in thread-safe manner

func (*PriorityStrategy) GetExceedMaxResolvedPeers

func (ps *PriorityStrategy) GetExceedMaxResolvedPeers() int32

GetExceedMaxResolvedPeers returns number of peers exceeding max number of the resolved peers

func (*PriorityStrategy) GetExceedMaxUnresolvedPeers

func (ps *PriorityStrategy) GetExceedMaxUnresolvedPeers() int32

GetExceedMaxUnresolvedPeers returns number of peers exceeding max number of the unresolved peers

func (*PriorityStrategy) GetHostInfo

func (ps *PriorityStrategy) GetHostInfo() *model.Node

func (*PriorityStrategy) GetMorePeersHandler

func (ps *PriorityStrategy) GetMorePeersHandler() (*model.Peer, error)

GetMorePeersHandler request peers to random peer in list and if get new peers will add to unresolved peer

func (*PriorityStrategy) GetMorePeersThread

func (ps *PriorityStrategy) GetMorePeersThread()

GetMorePeersThread to periodically request more peers from another node in Peers list

func (*PriorityStrategy) GetPriorityPeers

func (ps *PriorityStrategy) GetPriorityPeers() map[string]*model.Peer

GetPriorityPeers To get a list peer should connect if host in scramble node

func (*PriorityStrategy) GetPriorityPeersByFullAddress

func (ps *PriorityStrategy) GetPriorityPeersByFullAddress(priorityPeers map[string]*model.Peer) map[string]*model.Peer

getPriorityPeersByFullAddress build a priority peers map with only peers that have and address

func (*PriorityStrategy) GetReplaceableUnresolvedPeer

func (ps *PriorityStrategy) GetReplaceableUnresolvedPeer(scrambledNodes *model.ScrambledNodes) *model.Peer

func (*PriorityStrategy) GetResolvedPeerByAddressPort

func (ps *PriorityStrategy) GetResolvedPeerByAddressPort(addressPort string) (peer *model.Peer)

func (*PriorityStrategy) GetResolvedPeers

func (ps *PriorityStrategy) GetResolvedPeers() map[string]*model.Peer

GetResolvedPeers returns resolved peers in thread-safe manner

func (*PriorityStrategy) GetTotalResolvedPeers

func (ps *PriorityStrategy) GetTotalResolvedPeers() (totalResolvedPeers int32)

func (*PriorityStrategy) GetTotalUnresolvedPeers

func (ps *PriorityStrategy) GetTotalUnresolvedPeers() (totalUnresolvedPeers int32)

GetTotalUnresolvedPeers to get a number of unresloved peers

func (*PriorityStrategy) GetUnresolvedPeerByAddressPort

func (ps *PriorityStrategy) GetUnresolvedPeerByAddressPort(addressPort string) (peer *model.Peer)

GetUnresolvedPeerByAddressPort to get unresolved peer by full address port peer

func (*PriorityStrategy) GetUnresolvedPeers

func (ps *PriorityStrategy) GetUnresolvedPeers() map[string]*model.Peer

GetUnresolvedPeers returns unresolved peers in thread-safe manner

func (*PriorityStrategy) PeerBlacklist

func (ps *PriorityStrategy) PeerBlacklist(peer *model.Peer, cause string) error

PeerBlacklist process adding peer into blacklist

func (*PriorityStrategy) PeerUnblacklist

func (ps *PriorityStrategy) PeerUnblacklist(peer *model.Peer) *model.Peer

PeerUnblacklist to update Peer state of peer

func (*PriorityStrategy) ReceiveNodeAddressInfo

func (ps *PriorityStrategy) ReceiveNodeAddressInfo(nodeAddressInfo []*model.NodeAddressInfo) error

ReceiveNodeAddressInfo receive a node address info from a peer and save it to db

func (*PriorityStrategy) RemoveBlacklistedPeer

func (ps *PriorityStrategy) RemoveBlacklistedPeer(peer *model.Peer) error

RemoveBlacklistedPeer removes peer from Blacklisted peer list

func (*PriorityStrategy) RemoveResolvedPeer

func (ps *PriorityStrategy) RemoveResolvedPeer(peer *model.Peer) error

RemoveResolvedPeer removes peer from Resolved peer list

func (*PriorityStrategy) RemoveUnresolvedPeer

func (ps *PriorityStrategy) RemoveUnresolvedPeer(peer *model.Peer) error

RemoveUnresolvedPeer removes peer from unresolved peer list

func (*PriorityStrategy) ResolvePeers

func (ps *PriorityStrategy) ResolvePeers()

ResolvePeers looping unresolved peers and adding to (resolve) Peers if get response

func (*PriorityStrategy) ResolvePeersThread

func (ps *PriorityStrategy) ResolvePeersThread()

ResolvePeersThread to periodically try get response from peers in UnresolvedPeer list

func (*PriorityStrategy) Start

func (ps *PriorityStrategy) Start()

Start method to start threads which mean goroutines for PriorityStrategy

func (*PriorityStrategy) SyncNodeAddressInfoTable

func (ps *PriorityStrategy) SyncNodeAddressInfoTable(nodeRegistrations []*model.NodeRegistration) (map[int64]*model.NodeAddressInfo, error)

SyncNodeAddressInfoTable synchronize node_address_info table by downloading and merging all addresses from peers Note: the node will try to rebroadcast every node address that is updated (new or updated version of an existing one)

func (*PriorityStrategy) SyncNodeAddressInfoTableThread

func (ps *PriorityStrategy) SyncNodeAddressInfoTableThread()

func (*PriorityStrategy) UpdateBlacklistedStatusThread

func (ps *PriorityStrategy) UpdateBlacklistedStatusThread()

UpdateBlacklistedStatusThread to periodically check blacklisting time of black listed peer, every 60sec if there are blacklisted peers to unblacklist

func (*PriorityStrategy) UpdateNodeAddressThread

func (ps *PriorityStrategy) UpdateNodeAddressThread()

UpdateNodeAddressThread to periodically update node own's dynamic address and broadcast it note: if address is dynamic, if will be fetched periodically from internet, but will be re-broadcast only if it is changed

func (*PriorityStrategy) UpdateOwnNodeAddressInfo

func (ps *PriorityStrategy) UpdateOwnNodeAddressInfo(nodeAddress string, port uint32, forceBroadcast bool) error

UpdateOwnNodeAddressInfo check if nodeAddress in db must be updated and broadcast the new address

func (*PriorityStrategy) UpdateResolvedPeers

func (ps *PriorityStrategy) UpdateResolvedPeers()

UpdateResolvedPeers use to maintaining resolved peers

func (*PriorityStrategy) ValidatePriorityPeer

func (ps *PriorityStrategy) ValidatePriorityPeer(scrambledNodes *model.ScrambledNodes, host, peer *model.Node) bool

ValidatePriorityPeer, check peer is in priority list peer of host node

func (*PriorityStrategy) ValidateRangePriorityPeers

func (ps *PriorityStrategy) ValidateRangePriorityPeers(peerIndex, hostStartPeerIndex, hostEndPeerIndex int) bool

func (*PriorityStrategy) ValidateRequest

func (ps *PriorityStrategy) ValidateRequest(ctx context.Context) bool

ValidateRequest to validate incoming request based on metadata in context and Priority strategy

func (*PriorityStrategy) ValidateScrambleNode

func (ps *PriorityStrategy) ValidateScrambleNode(scrambledNodes *model.ScrambledNodes, node *model.Node) bool

ValidateScrambleNode, check node in scramble or not

Jump to

Keyboard shortcuts

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