Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a concurrency-safe nonce store with TTL-based expiry. It is used to detect and reject replayed beacon nonces.
func NewBoundedCache ¶
NewBoundedCache creates a nonce cache with an explicit hard entry cap.
func (*Cache) SeenOrAdd ¶
SeenOrAdd atomically checks whether n was already seen and, if not, records it. Returns true if n was already present (replay; caller should reject). Returns false if n was new (caller may proceed); the nonce is recorded under the same lock.
Callers must use SeenOrAdd rather than the separate Seen+Add pair to prevent a TOCTOU race where two concurrent requests carrying the same nonce both pass Seen before either calls Add.
Click to show internal directories.
Click to hide internal directories.