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.
Nebula · Packages/com.1by3.nebula/Runtime/Worker/AuthorityCallContract.cspublic sealed class AuthorityCallRouterThe 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:
- The entity is unknown here:
AuthorityCallOutcome.RejectedUnknownEntity. - The call's epoch is ahead of the entity's, or more than
MaxHopsbehind 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 thanMaxHopsbehind; anything further behind came from a copy that had missed several authority changes (design D3). - This worker has authority: apply, unless the ledger has the id, which is
AuthorityCallOutcome.RejectedDuplicate(design D5). - The call has already been forwarded
MaxHopstimes:AuthorityCallOutcome.RejectedHopLimit(design D4). - 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.
| Parameter | Description |
|---|---|
callId | The id the sender minted. |
callEpoch | The entity epoch the sender observed when it made the call. |
hops | How many times the call has been forwarded before reaching this worker. |
target | What this worker knows about the entity. |
tick | This 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.