-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3749 from ElrondNetwork/resolvers
PeerAuthenticationResolver
- Loading branch information
Showing
21 changed files
with
1,220 additions
and
267 deletions.
There are no files selected for viewing
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
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
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
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
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
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,20 @@ | ||
package mock | ||
|
||
// NodesCoordinatorStub - | ||
type NodesCoordinatorStub struct { | ||
GetAllEligibleValidatorsPublicKeysCalled func(epoch uint32) (map[uint32][][]byte, error) | ||
} | ||
|
||
// GetAllEligibleValidatorsPublicKeys - | ||
func (nc *NodesCoordinatorStub) GetAllEligibleValidatorsPublicKeys(epoch uint32) (map[uint32][][]byte, error) { | ||
if nc.GetAllEligibleValidatorsPublicKeysCalled != nil { | ||
return nc.GetAllEligibleValidatorsPublicKeysCalled(epoch) | ||
} | ||
|
||
return nil, nil | ||
} | ||
|
||
// IsInterfaceNil - | ||
func (nc *NodesCoordinatorStub) IsInterfaceNil() bool { | ||
return nc == nil | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,55 @@ | ||
package resolvers | ||
|
||
import ( | ||
"github.com/ElrondNetwork/elrond-go-core/core/check" | ||
"github.com/ElrondNetwork/elrond-go-core/marshal" | ||
"github.com/ElrondNetwork/elrond-go/dataRetriever" | ||
) | ||
|
||
// ArgBaseResolver is the argument structure used as base to create a new a resolver instance | ||
type ArgBaseResolver struct { | ||
SenderResolver dataRetriever.TopicResolverSender | ||
Marshalizer marshal.Marshalizer | ||
AntifloodHandler dataRetriever.P2PAntifloodHandler | ||
Throttler dataRetriever.ResolverThrottler | ||
} | ||
|
||
type baseResolver struct { | ||
dataRetriever.TopicResolverSender | ||
} | ||
|
||
func checkArgBase(arg ArgBaseResolver) error { | ||
if check.IfNil(arg.SenderResolver) { | ||
return dataRetriever.ErrNilResolverSender | ||
} | ||
if check.IfNil(arg.Marshalizer) { | ||
return dataRetriever.ErrNilMarshalizer | ||
} | ||
if check.IfNil(arg.AntifloodHandler) { | ||
return dataRetriever.ErrNilAntifloodHandler | ||
} | ||
if check.IfNil(arg.Throttler) { | ||
return dataRetriever.ErrNilThrottler | ||
} | ||
return nil | ||
} | ||
|
||
// SetNumPeersToQuery will set the number of intra shard and cross shard number of peer to query | ||
func (res *baseResolver) SetNumPeersToQuery(intra int, cross int) { | ||
res.TopicResolverSender.SetNumPeersToQuery(intra, cross) | ||
} | ||
|
||
// NumPeersToQuery will return the number of intra shard and cross shard number of peer to query | ||
func (res *baseResolver) NumPeersToQuery() (int, int) { | ||
return res.TopicResolverSender.NumPeersToQuery() | ||
} | ||
|
||
// SetResolverDebugHandler will set a resolver debug handler | ||
func (res *baseResolver) SetResolverDebugHandler(handler dataRetriever.ResolverDebugHandler) error { | ||
return res.TopicResolverSender.SetResolverDebugHandler(handler) | ||
} | ||
|
||
// Close returns nil | ||
func (res *baseResolver) Close() error { | ||
return 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
Oops, something went wrong.