Documentation ¶
Index ¶
- Constants
- func NewNodeAddress(seed uint16) string
- func NewNodeID(seed uint16) string
- func NewProTxHash(seed uint16) []byte
- func NewProTxHashes(seeds ...uint16) []bytes.HexBytes
- func NewQuorumHash(seed uint16) []byte
- func NewValidator(seed uint16) *types.Validator
- func NewValidators(n uint16) []*types.Validator
- func ValidatorsProTxHashes(vals []*types.Validator) []bytes.HexBytes
- type DashDialer
- type HistoryEvent
Constants ¶
const ( OpDial = "dialOne" OpStop = "stopOne" )
Variables ¶
This section is empty.
Functions ¶
func NewNodeAddress ¶
NewNodeAddress generates a string that is accepted as validator address. For given `seed`, the address will always be the same.
func NewNodeID ¶
NewNodeID generates new deterministic node ID. For a given `uniqueID`, the node ID is always the same.
func NewProTxHash ¶
NewProTxHash generates a deterministic proTxHash. For the same `seed`, generated data is always the same.
func NewProTxHashes ¶
NewProTxHashes generates multiple deterministic proTxHash'es using mockProTxHash. Each argument will be passed to mockProTxHash. Each proTxHash will use provided `seed`
func NewQuorumHash ¶
NewQuorumHash generates a deterministic quorum hash. For the same `seed`, generated data is always the same.
func NewValidator ¶
NewValidator generates a validator with only fields needed for node selection filled. For the same `seed`, mock validator will always have the same data (proTxHash, NodeID)
func NewValidators ¶
NewValidators generates a slice containing `n` mock validators. Each element is generated using `mock.NewValidator()`.
Types ¶
type DashDialer ¶
type DashDialer struct { ConnectedPeers map[types.NodeID]bool HistoryChan chan HistoryEvent // contains filtered or unexported fields }
DashDialer is a mock `p2p.DashDialer`. It sends event about DialPeersAsync() and StopPeerGracefully() calls to HistoryChan and stores them in History
func NewDashDialer ¶
func NewDashDialer() *DashDialer
NewDashDialer creates a new mock p2p.DashDialer that sends notifications on all events to HistoryChan channel.
func (*DashDialer) ConnectAsync ¶
func (sw *DashDialer) ConnectAsync(addr p2p.NodeAddress) error
ConnectAsync implements p2p.DashDialer. It emulates connecting to provided address, adds is as a connected peer and emits history event OpDial.
func (*DashDialer) DisconnectAsync ¶
func (sw *DashDialer) DisconnectAsync(id types.NodeID) error
DisconnectAsync implements p2p.DashDialer. It removes the peer from list of connected peers and emits history event OpStop
func (*DashDialer) IsDialingOrConnected ¶
func (sw *DashDialer) IsDialingOrConnected(id types.NodeID) bool
IsDialingOrConnected implements p2p.DashDialer. It checks if provided peer is connected or dial is in progress.
func (*DashDialer) Resolve ¶
func (sw *DashDialer) Resolve(val types.ValidatorAddress) (p2p.NodeAddress, error)
type HistoryEvent ¶
HistoryEvent is a log of dial and stop operations executed by the DashDialer