Class HastingsDiscovery
Inheritance
System.Object
HastingsDiscovery
Implements
System.IDisposable
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Assembly: Catalyst.Core.Modules.P2P.Discovery.Hastings.dll
Syntax
public class HastingsDiscovery : IPeerDiscovery, IDisposable
Constructors
|
Improve this Doc
View Source
HastingsDiscovery(ILogger, IPeerRepository, IDns, IPeerSettings, IPeerClient, IPeerMessageCorrelationManager, ICancellationTokenProvider, IEnumerable<IPeerClientObservable>, Boolean, Int32, IHastingsOriginator, IHastingsCareTaker, Int32, Int32)
Declaration
public HastingsDiscovery(ILogger logger, IPeerRepository peerRepository, IDns dns, IPeerSettings peerSettings, IPeerClient peerClient, IPeerMessageCorrelationManager peerMessageCorrelationManager, ICancellationTokenProvider cancellationTokenProvider, IEnumerable<IPeerClientObservable> peerClientObservables, bool autoStart = true, int peerDiscoveryBurnIn = 10, IHastingsOriginator stepProposal = null, IHastingsCareTaker hastingsCareTaker = null, int millisecondsTimeout = 10000, int hasValidCandidatesCheckMillisecondsFrequency = 1000)
Parameters
Fields
|
Improve this Doc
View Source
PeerDiscoveryBurnIn
Declaration
protected readonly int PeerDiscoveryBurnIn
Field Value
Type |
Description |
System.Int32 |
|
|
Improve this Doc
View Source
PeerRepository
Declaration
public readonly IPeerRepository PeerRepository
Field Value
Properties
|
Improve this Doc
View Source
CurrentStep
Declaration
public IHastingsMemento CurrentStep { get; }
Property Value
|
Improve this Doc
View Source
DiscoveryStream
Declaration
public IObservable<IPeerClientMessageDto> DiscoveryStream { get; }
Property Value
|
Improve this Doc
View Source
HastingsCareTaker
Declaration
public IHastingsCareTaker HastingsCareTaker { get; }
Property Value
|
Improve this Doc
View Source
PeerClient
Declaration
public IPeerClient PeerClient { get; }
Property Value
|
Improve this Doc
View Source
StepProposal
Declaration
public IHastingsOriginator StepProposal { get; }
Property Value
Methods
|
Improve this Doc
View Source
DiscoveryAsync()
Discovery mechanism for Hasting metropolis walk.
method loops until we can build up a valid next state,
a valid next state is when we see a sum of events on our Discovery stream that
equal to the number of peers we tried to discover. The discovery streams is merged from
PeerCorrelation cache where we listen for evicted pingResponses (the ones we sen to try discover the peer),
and PingResponses. Expected PingResponse messages indicate a potential neighbour has responded to our ping,
so we assume it is reachable, so we add this to the StepProposal.CurrentNeighbours.
Once the sum of StepProposal.CurrentNeighbours and EvictedPingResponses equals the total expected responses,
At this point we received all the potential messages we could, if we have potential peers for the next step, then
we can walk forward.
if not the condition has not been met within a timeout then we walk back by taking the last known state from the
IHastingCaretaker.
Declaration
public Task DiscoveryAsync()
Returns
Type |
Description |
System.Threading.Tasks.Task |
|
|
Improve this Doc
View Source
Dispose()
Declaration
|
Improve this Doc
View Source
Dispose(Boolean)
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type |
Name |
Description |
System.Boolean |
disposing |
|
|
Improve this Doc
View Source
EvictionCallback(ICorrelationId)
OnNext method for _evictionSubscription
handles the discovery messages to see if there of interest to us.
Declaration
protected void EvictionCallback(ICorrelationId requestCorrelationId)
Parameters
Type |
Name |
Description |
ICorrelationId |
requestCorrelationId |
Correlation Id for the request getting evicted.
|
|
Improve this Doc
View Source
StorePeer(INeighbour)
Stores a peer in the database unless we are in the burn-in phase.
Declaration
protected void StorePeer(INeighbour neighbour)
Parameters
|
Improve this Doc
View Source
WalkBack()
Transition back to last state.
Declaration
protected void WalkBack()
|
Improve this Doc
View Source
WalkForward()
Transitions StepProposal to state,
then start to try building next StepProposal.
Declaration
protected void WalkForward()
Implements
System.IDisposable