Expand description
§tsoracle-core
Sync algorithm core for the tsoracle timestamp oracle.
No I/O, no async, no tokio. Runtime-neutral, property-testable in microseconds. Anything you need to reason about tsoracle’s timestamp generation lives here — the higher layers (tsoracle-server, tsoracle-client, the consensus drivers) are wiring around this core.
§What’s in the box
Allocator— the window allocator. Hands out 46/18-bit-packedTimestamps within a granted window, tracks the leader’s epoch, and exposes theWindowGrantlifecycle used by the server’s leader-watch + fence pipeline.Timestamp— the 64-bit packed representation.PHYSICAL_MS_MAXandLOGICAL_MAXdocument the bit budget;TimestampErrorcovers the narrow space of invalid encodings.Epoch— the leader-watermark identifier the failover fence checks. Persisted alongside the high water by everyConsensusDriverimpl.CoreError— the algorithm-level error type. Server, client, and driver crates wrap it in their own variants.
§Feature flags
std(default) — enablesstd-dependent surface (most of it). Disabling gives ano_stdcore; the public surface shrinks but the allocator + timestamp math still work.serde— derivesSerialize/Deserializeon the public types so they cross wire and storage boundaries cleanly.
§Documentation
docs/architecture-deep-dive.md— the algorithm and bit-packing contract this crate implements.docs/consensus-integration.md— how theAllocatorinteracts with aConsensusDriverimpl.
Re-exports§
pub use seq::DEFAULT_MAX_SEQ_BATCH_KEYS;pub use seq::DEFAULT_MAX_SEQ_COUNT;pub use seq::MAX_SEQ_KEY_LEN;pub use seq::SeqAllocator;pub use seq::SeqGrant;pub use seq::SeqKey;
Modules§
- docs
- Long-form documentation for tsoracle-core.
- seq
- Keyed dense sequence types: validated keys, contiguous grants, and the
leadership/epoch gate. Pure and synchronous, no I/O — the same discipline as
allocator.rs. UnlikeAllocator, this holds NO per-key counter state: every counter lives in the durable layer and every blockstartis assigned there.
Structs§
- Allocator
- Epoch
- Lease
Record - Durable lease state.
- Lease
Table - Pure lease table keyed by lease_id.
- Peer
Endpoint - A scheme-less
host:portadvertising the tsoracle service address of a peer node. - Physical
Ms - A
u64physical-millisecond value proven<= PHYSICAL_MS_MAXat construction. - Timestamp
- TsoPeer
- A known peer node and the network endpoint where its TSO service can be reached for follower-redirect hints.
- Window
Grant - A contiguous block of
counttimestamps starting at(physical_ms, logical_start), all sharing one leadershipepoch.
Enums§
- Acquire
Decision - Outcome of
prepare_acquire. - Commit
Outcome - The result of a
try_commit_window_extensionthat passed range validation. - Core
Error - Ignore
Reason - Why a
CommitOutcome::Ignoredcommit left the durable bound unchanged. - Lease
Error - Peer
Endpoint Error - Error returned when a string fails the
PeerEndpointcontract. - Timestamp
Error
Constants§
- DEFAULT_
LEASE_ TTL_ CEILING_ MS - Default server-enforced upper bound on requested lease TTLs (300 s).
- DEFAULT_
LEASE_ TTL_ FLOOR_ MS - Default server-enforced lower bound on requested lease TTLs (5 s).
- LOGICAL_
MAX - MAX_
LEASE_ HOLDER_ LEN - Maximum accepted length of the opaque holder key, in bytes.
- PHYSICAL_
MS_ MAX
Functions§
- validate_
lease_ request - Validate an AcquireLease request against server TTL policy. Floor and ceiling are server configuration.