Class X402::BSV::ChallengeStore::Memory ¶
Inherits: Object
In-memory backend suitable for development and single-process deployments. Thread-safe via Monitor. Entries expire after ttl seconds and the store rejects new challenges once max_issued unconsumed entries are held.
NOTE: This store is per-process. It provides no replay protection across OS processes (e.g. Puma pre-fork, multiple dynos). Production multi-process deployments should use a shared backend.
Constants¶
DEFAULT_MAX_ISSUED ¶
Not documented.
DEFAULT_TTL ¶
Not documented.
Public Instance Methods¶
consume!(hash) ¶
Atomically remove an entry. Returns true if it was present and active, false otherwise. Safe to call from the settlement path without a prior lookup. - @param hash [String] - @return [Boolean]
initialize(ttl: = DEFAULT_TTL, max_issued: = DEFAULT_MAX_ISSUED) ¶
- @param
ttl[Integer] seconds before an issued challenge expires - @param
max_issued[Integer] cap on unconsumed entries - @return [Memory] a new instance of Memory
lookup(hash) ¶
Non-binding read: returns the cached challenge or nil. - @param hash [String] - @return [X402::Challenge, nil]
store!(hash, challenge) ¶
Record an issued challenge. - @param hash [String] hex-encoded canonical sha256 of the challenge - @param challenge [X402::Challenge] - @raise [StoreFullError] if max_issued entries are held - @return [void]