-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
285 additions
and
49 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
node/processingOnlyNode/configLoaders.go → node/chainSimulator/configLoaders.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package processingOnlyNode | ||
package chainSimulator | ||
|
||
import ( | ||
"os" | ||
|
2 changes: 1 addition & 1 deletion
2
node/processingOnlyNode/coreComponents.go → node/chainSimulator/coreComponents.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package processingOnlyNode | ||
package chainSimulator | ||
|
||
import ( | ||
"bytes" | ||
|
2 changes: 1 addition & 1 deletion
2
node/processingOnlyNode/cryptoComponents.go → node/chainSimulator/cryptoComponents.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package processingOnlyNode | ||
package chainSimulator | ||
|
||
import ( | ||
"fmt" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package disabled | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/multiversx/mx-chain-core-go/core" | ||
"github.com/multiversx/mx-chain-go/p2p" | ||
"github.com/multiversx/mx-chain-go/process" | ||
) | ||
|
||
type antiFlooder struct { | ||
} | ||
|
||
// NewAntiFlooder creates a new instance of disabled antiflooder | ||
func NewAntiFlooder() *antiFlooder { | ||
return &antiFlooder{} | ||
} | ||
|
||
// CanProcessMessage returns nil | ||
func (a *antiFlooder) CanProcessMessage(_ p2p.MessageP2P, _ core.PeerID) error { | ||
return nil | ||
} | ||
|
||
// IsOriginatorEligibleForTopic does nothing and returns nil | ||
func (a *antiFlooder) IsOriginatorEligibleForTopic(_ core.PeerID, _ string) error { | ||
return nil | ||
} | ||
|
||
// CanProcessMessagesOnTopic does nothing and returns nil | ||
func (a *antiFlooder) CanProcessMessagesOnTopic(_ core.PeerID, _ string, _ uint32, _ uint64, _ []byte) error { | ||
return nil | ||
} | ||
|
||
// ApplyConsensusSize does nothing | ||
func (a *antiFlooder) ApplyConsensusSize(_ int) { | ||
} | ||
|
||
// SetDebugger does nothing and returns nil | ||
func (a *antiFlooder) SetDebugger(_ process.AntifloodDebugger) error { | ||
return nil | ||
} | ||
|
||
// BlacklistPeer does nothing | ||
func (a *antiFlooder) BlacklistPeer(_ core.PeerID, _ string, _ time.Duration) { | ||
} | ||
|
||
// ResetForTopic does nothing | ||
func (a *antiFlooder) ResetForTopic(_ string) { | ||
} | ||
|
||
// SetMaxMessagesForTopic does nothing | ||
func (a *antiFlooder) SetMaxMessagesForTopic(_ string, _ uint32) { | ||
} | ||
|
||
// SetPeerValidatorMapper does nothing and returns nil | ||
func (a *antiFlooder) SetPeerValidatorMapper(_ process.PeerValidatorMapper) error { | ||
return nil | ||
} | ||
|
||
// SetTopicsForAll does nothing | ||
func (a *antiFlooder) SetTopicsForAll(_ ...string) { | ||
} | ||
|
||
// Close does nothing and returns nil | ||
func (a *antiFlooder) Close() error { | ||
return nil | ||
} | ||
|
||
// IsInterfaceNil returns true if there is no value under the interface | ||
func (a *antiFlooder) IsInterfaceNil() bool { | ||
return a == nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package disabled | ||
|
||
type peerHonesty struct { | ||
} | ||
|
||
// NewPeerHonesty creates a new instance of disabled peer honesty | ||
func NewPeerHonesty() *peerHonesty { | ||
return &peerHonesty{} | ||
} | ||
|
||
// ChangeScore does nothing | ||
func (p *peerHonesty) ChangeScore(_ string, _ string, _ int) { | ||
} | ||
|
||
// Close does nothing and returns nil | ||
func (p *peerHonesty) Close() error { | ||
return nil | ||
} | ||
|
||
// IsInterfaceNil returns true if there is no value under the interface | ||
func (p *peerHonesty) IsInterfaceNil() bool { | ||
return p == nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package disabled | ||
|
||
import "github.com/multiversx/mx-chain-go/p2p" | ||
|
||
type peersRatingMonitor struct { | ||
} | ||
|
||
// NewPeersRatingMonitor will create a new disabled peersRatingMonitor instance | ||
func NewPeersRatingMonitor() *peersRatingMonitor { | ||
return &peersRatingMonitor{} | ||
} | ||
|
||
// GetConnectedPeersRatings returns an empty string since it is a disabled component | ||
func (monitor *peersRatingMonitor) GetConnectedPeersRatings(_ p2p.ConnectionsHandler) (string, error) { | ||
return "", nil | ||
} | ||
|
||
// IsInterfaceNil returns true if there is no value under the interface | ||
func (monitor *peersRatingMonitor) IsInterfaceNil() bool { | ||
return monitor == nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package chainSimulator | ||
|
||
import "github.com/multiversx/mx-chain-core-go/core" | ||
|
||
// SyncedBroadcastNetworkHandler defines the synced network interface | ||
type SyncedBroadcastNetworkHandler interface { | ||
RegisterMessageReceiver(handler messageReceiver, pid core.PeerID) | ||
Broadcast(pid core.PeerID, topic string, buff []byte) | ||
SendDirectly(from core.PeerID, topic string, buff []byte, to core.PeerID) error | ||
GetConnectedPeers() []core.PeerID | ||
GetConnectedPeersOnTopic(topic string) []core.PeerID | ||
IsInterfaceNil() bool | ||
} |
2 changes: 1 addition & 1 deletion
2
node/processingOnlyNode/memoryComponents.go → node/chainSimulator/memoryComponents.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package processingOnlyNode | ||
package chainSimulator | ||
|
||
import ( | ||
"github.com/multiversx/mx-chain-go/storage" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
package chainSimulator | ||
|
||
import ( | ||
disabledBootstrap "github.com/multiversx/mx-chain-go/epochStart/bootstrap/disabled" | ||
"github.com/multiversx/mx-chain-go/factory" | ||
disabledFactory "github.com/multiversx/mx-chain-go/factory/disabled" | ||
"github.com/multiversx/mx-chain-go/node/chainSimulator/disabled" | ||
"github.com/multiversx/mx-chain-go/p2p" | ||
disabledP2P "github.com/multiversx/mx-chain-go/p2p/disabled" | ||
"github.com/multiversx/mx-chain-go/process" | ||
disabledAntiflood "github.com/multiversx/mx-chain-go/process/throttle/antiflood/disabled" | ||
) | ||
|
||
type networkComponentsHolder struct { | ||
networkMessenger p2p.Messenger | ||
inputAntiFloodHandler factory.P2PAntifloodHandler | ||
outputAntiFloodHandler factory.P2PAntifloodHandler | ||
pubKeyCacher process.TimeCacher | ||
peerBlackListHandler process.PeerBlackListCacher | ||
peerHonestyHandler factory.PeerHonestyHandler | ||
preferredPeersHolderHandler factory.PreferredPeersHolderHandler | ||
peersRatingHandler p2p.PeersRatingHandler | ||
peersRatingMonitor p2p.PeersRatingMonitor | ||
fullArchiveNetworkMessenger p2p.Messenger | ||
fullArchivePreferredPeersHolderHandler factory.PreferredPeersHolderHandler | ||
} | ||
|
||
// CreateNetworkComponentsHolder creates a new networkComponentsHolder instance | ||
func CreateNetworkComponentsHolder(network SyncedBroadcastNetworkHandler) (*networkComponentsHolder, error) { | ||
messenger, err := NewSyncedMessenger(network) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &networkComponentsHolder{ | ||
networkMessenger: messenger, | ||
inputAntiFloodHandler: disabled.NewAntiFlooder(), | ||
outputAntiFloodHandler: disabled.NewAntiFlooder(), | ||
pubKeyCacher: &disabledAntiflood.TimeCache{}, | ||
peerBlackListHandler: &disabledAntiflood.PeerBlacklistCacher{}, | ||
peerHonestyHandler: disabled.NewPeerHonesty(), | ||
preferredPeersHolderHandler: disabledFactory.NewPreferredPeersHolder(), | ||
peersRatingHandler: disabledBootstrap.NewDisabledPeersRatingHandler(), | ||
peersRatingMonitor: disabled.NewPeersRatingMonitor(), | ||
fullArchiveNetworkMessenger: disabledP2P.NewNetworkMessenger(), | ||
fullArchivePreferredPeersHolderHandler: disabledFactory.NewPreferredPeersHolder(), | ||
}, nil | ||
} | ||
|
||
// NetworkMessenger returns the network messenger | ||
func (holder *networkComponentsHolder) NetworkMessenger() p2p.Messenger { | ||
return holder.networkMessenger | ||
} | ||
|
||
// InputAntiFloodHandler returns the input antiflooder | ||
func (holder *networkComponentsHolder) InputAntiFloodHandler() factory.P2PAntifloodHandler { | ||
return holder.inputAntiFloodHandler | ||
} | ||
|
||
// OutputAntiFloodHandler returns the output antiflooder | ||
func (holder *networkComponentsHolder) OutputAntiFloodHandler() factory.P2PAntifloodHandler { | ||
return holder.outputAntiFloodHandler | ||
} | ||
|
||
// PubKeyCacher returns the public key cacher | ||
func (holder *networkComponentsHolder) PubKeyCacher() process.TimeCacher { | ||
return holder.pubKeyCacher | ||
} | ||
|
||
// PeerBlackListHandler returns the peer blacklist handler | ||
func (holder *networkComponentsHolder) PeerBlackListHandler() process.PeerBlackListCacher { | ||
return holder.peerBlackListHandler | ||
} | ||
|
||
// PeerHonestyHandler returns the peer honesty handler | ||
func (holder *networkComponentsHolder) PeerHonestyHandler() factory.PeerHonestyHandler { | ||
return holder.peerHonestyHandler | ||
} | ||
|
||
// PreferredPeersHolderHandler returns the preferred peers holder | ||
func (holder *networkComponentsHolder) PreferredPeersHolderHandler() factory.PreferredPeersHolderHandler { | ||
return holder.preferredPeersHolderHandler | ||
} | ||
|
||
// PeersRatingHandler returns the peers rating handler | ||
func (holder *networkComponentsHolder) PeersRatingHandler() p2p.PeersRatingHandler { | ||
return holder.peersRatingHandler | ||
} | ||
|
||
// PeersRatingMonitor returns the peers rating monitor | ||
func (holder *networkComponentsHolder) PeersRatingMonitor() p2p.PeersRatingMonitor { | ||
return holder.peersRatingMonitor | ||
} | ||
|
||
// FullArchiveNetworkMessenger returns the full archive network messenger | ||
func (holder *networkComponentsHolder) FullArchiveNetworkMessenger() p2p.Messenger { | ||
return holder.fullArchiveNetworkMessenger | ||
} | ||
|
||
// FullArchivePreferredPeersHolderHandler returns the full archive preferred peers holder | ||
func (holder *networkComponentsHolder) FullArchivePreferredPeersHolderHandler() factory.PreferredPeersHolderHandler { | ||
return holder.fullArchivePreferredPeersHolderHandler | ||
} | ||
|
||
// IsInterfaceNil returns true if there is no value under the interface | ||
func (holder *networkComponentsHolder) IsInterfaceNil() bool { | ||
return holder == nil | ||
} |
2 changes: 1 addition & 1 deletion
2
node/processingOnlyNode/stateComponents.go → node/chainSimulator/stateComponents.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
node/processingOnlyNode/statusComponents.go → node/chainSimulator/statusComponents.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package processingOnlyNode | ||
package chainSimulator | ||
|
||
import ( | ||
"time" | ||
|
2 changes: 1 addition & 1 deletion
2
...rocessingOnlyNode/statusCoreComponents.go → node/chainSimulator/statusCoreComponents.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package processingOnlyNode | ||
package chainSimulator | ||
|
||
import ( | ||
"github.com/multiversx/mx-chain-core-go/core" | ||
|
2 changes: 1 addition & 1 deletion
2
node/processingOnlyNode/storageService.go → node/chainSimulator/storageService.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package processingOnlyNode | ||
package chainSimulator | ||
|
||
import ( | ||
"github.com/multiversx/mx-chain-go/dataRetriever" | ||
|
2 changes: 1 addition & 1 deletion
2
...cessingOnlyNode/syncedBroadcastNetwork.go → .../chainSimulator/syncedBroadcastNetwork.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package processingOnlyNode | ||
package chainSimulator | ||
|
||
import ( | ||
"errors" | ||
|
2 changes: 1 addition & 1 deletion
2
...ngOnlyNode/syncedBroadcastNetwork_test.go → ...nSimulator/syncedBroadcastNetwork_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package processingOnlyNode | ||
package chainSimulator | ||
|
||
import ( | ||
"fmt" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...rocessingOnlyNode/syncedMessenger_test.go → node/chainSimulator/syncedMessenger_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package processingOnlyNode | ||
package chainSimulator | ||
|
||
import ( | ||
"fmt" | ||
|
Oops, something went wrong.