Nebula
Worker

AuthorityCallRouter

The rules every worker applies to an incoming AuthorityRpc call, in one place and with no engine types, so the worker, the standalone services and the conformance tests run the same code.

generated from the sources
public sealed class AuthorityCallRouter

The rules every worker applies to an incoming AuthorityRpc call, in one place and with no engine types, so the worker, the standalone services and the conformance tests run the same code. The rules, in the order they are checked:

  1. The entity is unknown here: AuthorityCallOutcome.RejectedUnknownEntity.
  2. The call's epoch is ahead of the entity's, or more than MaxHops behind it: AuthorityCallOutcome.RejectedStaleEpoch. A handover bumps the epoch by one and costs one forward, so a call that reached its authority within the hop bound is never more than MaxHops behind; anything further behind came from a copy that had missed several authority changes (design D3).
  3. This worker has authority: apply, unless the ledger has the id, which is AuthorityCallOutcome.RejectedDuplicate (design D5).
  4. The call has already been forwarded MaxHops times: AuthorityCallOutcome.RejectedHopLimit (design D4).
  5. There is a peer to forward to: forward. Otherwise AuthorityCallOutcome.RejectedUnreachable.

Constructors

AuthorityCallRouter

public AuthorityCallRouter(int maxHops, AuthorityCallLedger ledger = null);

Properties

MaxHops

public int MaxHops { get; }

Forwards a call may take after its first send, and the epoch lag tolerated with it. See NebulaConfig.AuthorityCallMaxHops.

Ledger

public AuthorityCallLedger Ledger { get; }

The applied-call ids this worker remembers.

Applied

public long Applied { get; }

Calls decided here by outcome, for the worker's statistics.

Forwarded

public long Forwarded { get; }

Rejected

public long Rejected { get; }

Methods

Decide

public AuthorityCallDecision Decide(ulong callId, uint callEpoch, byte hops, in AuthorityCallTarget target, uint tick);

Decide what to do with a call and record the decision. An AuthorityCallAction.Apply has already put the call id in the Ledger when this returns; the caller runs the method exactly then.

ParameterDescription
callIdThe id the sender minted.
callEpochThe entity epoch the sender observed when it made the call.
hopsHow many times the call has been forwarded before reaching this worker.
targetWhat this worker knows about the entity.
tickThis worker's current tick, for the ledger.

DecideOnly

public AuthorityCallDecision DecideOnly(uint callEpoch, byte hops, in AuthorityCallTarget target);

The rules without the ledger: what Decide does before it checks for a duplicate. An apply here may still be a AuthorityCallOutcome.RejectedDuplicate there.

IsStale

public bool IsStale(uint callEpoch, uint entityEpoch);

Whether a call made at callEpoch is too old (or too new) for an entity at entityEpoch: ahead of the entity, or more than MaxHops behind it.

On this page