RequestState class

State per request for multiple relays

Constructors

RequestState(NdkRequest request)
Creates a new RequestState instance

Properties

cacheController StreamController<Nip01Event>
cacheController is the controller cacheRead writes to
getter/setter pair
controller ↔ ReplaySubject<Nip01Event>
getter/setter pair
didAllRequestsFinish bool
checks if all requests finished (received EOSE or CLOSED)
no setter
hashCode int
The hash code for this object.
no setterinherited
id String
request id
no setter
isSubscription bool
is this a subscription?
no setter
networkController StreamController<Nip01Event>
networkController used by engines to write their response
getter/setter pair
onTimeout ↔ dynamic Function(RequestState)?
called when timeout is triggered
getter/setter pair
pendingConnections int
send paths still working out which connection to use, before they show up in requests. The relay that answers first must not look like the only one this request ever had, or the stream closes on the others
getter/setter pair
relayOutcomes Map<String, RelayRequestOutcome>
What the request ended with on each relay it was sent to, as it stands now
no setter
relayOutcomesStream Stream<Map<String, RelayRequestOutcome>>
relayOutcomes on every change, starting with what it holds right now, and closed once the request is over.
no setter
request NdkRequest
the original request
getter/setter pair
requests Map<RelayConnectionKey, RelayRequestState>
! our requests tracking obj
getter/setter pair
returnedIds Set<String>
ids that got already returned by this request
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
servedBy RequestState?
request this one was merged into by the concurrency check, when its stream got replaced by an identical request already in flight
getter/setter pair
stream Stream<Nip01Event>
no setter
timedOut bool
set when the request ended on its timeout instead of on the relays
getter/setter pair
timeoutDuration Duration?
timeout duration, closes all streams
getter/setter pair
unresolvedFilters List<Filter>
this is the working filter obj, gets initialized with user provided filters. Then on each step (cache, network) resolved filters get removed/updated
final

Methods

addRequest(RelayConnectionKey key, List<Filter> filters) → void
Adds single relay request to the state
addRequestForRelay(String url, List<Filter> filters) → void
Adds a request towards url on the connection this request's RelayAuth allows. A relay no connection can satisfy is skipped: falling back to the anonymous one is what the caller ruled out.
cancelTimeout() → void
Cancels the timeout timer without closing streams. Used when a duplicate request is detected and this request's stream will be fed from another in-flight request.
close() Future<void>
closes all streams
closeIfNoRelays() → void
Closes the network stream if the request was not sent to any relay. Engines call this once they are done dispatching: without a relay to answer, nothing would end the request but its timeout. A send path that is still working out its connection still counts, it may yet register one.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pauseTimeout() → void
Pauses the timeout timer. Call this before signing starts.
registerRequest(RelayConnectionKey key, List<Filter> filters) → void
Adds single relay request to the state, merging filters into the one already tracked on the same connection
removeRequest(RelayConnectionKey key) → void
Drops a relay request, for a relay the request could not be sent to
resumeTimeout() → void
Resumes the timeout timer. Call this after signing completes.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited