pub struct AttestationLog { /* private fields */ }Expand description
An append-only JSONL file.
Implementations§
Source§impl AttestationLog
impl AttestationLog
pub fn path(&self) -> &Path
Sourcepub fn append(&self, attestation: &PushAttestation) -> Result<()>
pub fn append(&self, attestation: &PushAttestation) -> Result<()>
Append one attestation as one line.
The whole record, JSON plus its newline, is handed to a single
write_all on a file opened O_APPEND, so two concurrent pushes cannot
interleave halves of two lines. A reader may therefore split on \n
without a parser, which is the only property JSONL actually promises.
Sourcepub fn append_line(&self, line: &str) -> Result<u64>
pub fn append_line(&self, line: &str) -> Result<u64>
Append one record that is not a push, and return its sequence
number — the zero-based line index it now sits at, which is also its
leaf index in the TransparencyLog over this file.
The metered appliance’s entitlement facts go through here
(crate::entitlement): every plan change is then a line under the
same signed tree heads as every push, so a service provider who edits
their own plan history is caught by the same audit that catches a
rewritten push. The line must be one JSON object with a top-level key
that is not a push’s — AttestationLog::read tells them apart by
ENTITLEMENT_KEY and RECLAIM_KEY — and must not contain a
newline.
Counting the existing lines is a read of the whole file, and that is
accepted: this is the rare path (a plan changes a few times a year per
tenant), and a sequence number that could be wrong would be worse than
one that costs a read. Two writers racing here can still interleave
their counts; the caller serialises (EntitlementSlot holds a mutex
across count-and-append).
Sourcepub fn read(&self) -> Result<Vec<PushAttestation>>
pub fn read(&self) -> Result<Vec<PushAttestation>>
Every push attestation in the log, in the order it was written.
Exposed because a log nothing can read back is a log nobody can check.
A record that is not a push (an entitlement line or a cache-reclaim
line, see AttestationLog::append_line) is skipped, which is why the
position in this vector is not a sequence number — use
AttestationLog::read_indexed for anything that proves inclusion.
Sourcepub fn read_indexed(&self) -> Result<Vec<(usize, PushAttestation)>>
pub fn read_indexed(&self) -> Result<Vec<(usize, PushAttestation)>>
AttestationLog::read, with each push’s line index — the number a
TransparencyLog proof is made against. The two are one function so
the index a verifier proves is the line the record was read from.
Trait Implementations§
Source§impl Clone for AttestationLog
impl Clone for AttestationLog
Auto Trait Implementations§
impl Freeze for AttestationLog
impl RefUnwindSafe for AttestationLog
impl Send for AttestationLog
impl Sync for AttestationLog
impl Unpin for AttestationLog
impl UnsafeUnpin for AttestationLog
impl UnwindSafe for AttestationLog
Blanket Implementations§
impl<T> Allocation for T
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request