You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(ttx): resolve envelope metrics via DI and add TypedSession
Addresses @adecaro's review on #1716:
- Metrics through dependency injection. NewEnvelopeMetrics is provided in
the dig container (token/sdk/dig) and registered as a resolvable
service; GetEnvelopeMetrics(sp) looks it up by type from a view
context (mirroring the existing reflect-based service resolvers).
Replaces the previous package-level RegisterMetrics/sync.Once.
- TypedSession. Introduce session.TypedSession (and NewTypedSession /
NewTypedSessionFromContext / NewTypedSessionToParty /
NewTypedSessionForCaller) which wraps a JSON session and resolves the
envelope metrics once from the view context. Its SendTyped /
ReceiveTyped / ReceiveTypedWithTimeout methods replace the static
helper calls across recipients, withdrawal, upgrade, endorse, accept,
auditor, collectactions, collectendorsements, multisig/boolpolicy
spend, and interop/htlc, so views no longer pass a session to package
functions and metrics are recorded automatically. SendEnvelopeOnSession
is removed in favour of TypedSession.
- Make endorse_test resolve services by requested type instead of by
call order, so the extra metrics lookup does not break it.
Signed-off-by: SuyashAlphaC <suyashagrawal862@gmail.com>
0 commit comments