Initialization constructor
Initialization({
- required NdkConfig ndkConfig,
- required GlobalState globalState,
NdkConfig is user defined GlobalState global state object that schuld stay in memory
Implementation
Initialization({
required NdkConfig ndkConfig,
required GlobalState globalState,
}) : _globalState = globalState, _ndkConfig = ndkConfig {
switch (_ndkConfig.engine) {
case NdkEngine.RELAY_SETS:
relayManager = RelayManager(
globalState: _globalState,
nostrTransportFactory: _webSocketNostrTransportFactory,
bootstrapRelays: _ndkConfig.bootstrapRelays,
);
engine = RelaySetsEngine(
cacheManager: _ndkConfig.cache,
globalState: _globalState,
relayManager: relayManager,
bootstrapRelays: _ndkConfig.bootstrapRelays,
);
break;
case NdkEngine.JIT:
relayManager = RelayManager<JitEngineRelayConnectivityData>(
globalState: _globalState,
nostrTransportFactory: _webSocketNostrTransportFactory,
bootstrapRelays: _ndkConfig.bootstrapRelays,
engineAdditionalDataFactory: JitEngineRelayConnectivityDataFactory(),
);
engine = JitEngine(
eventSigner: _ndkConfig.eventSigner,
cache: _ndkConfig.cache,
ignoreRelays: _ndkConfig.ignoreRelays,
relayManagerLight: relayManager,
globalState: _globalState,
);
break;
default:
throw UnimplementedError("Unknown engine");
}
/// repositories
final Nip05Repository nip05repository =
Nip05HttpRepositoryImpl(httpDS: _httpRequestDS);
/// use cases
cacheWrite = CacheWrite(_ndkConfig.cache);
cacheRead = CacheRead(_ndkConfig.cache);
requests = Requests(
globalState: _globalState,
cacheRead: cacheRead,
cacheWrite: cacheWrite,
networkEngine: engine,
eventVerifier: _ndkConfig.eventVerifier,
eventOutFilters: _ndkConfig.eventOutFilters,
);
broadcast = Broadcast(
globalState: _globalState,
cacheRead: cacheRead,
networkEngine: engine,
signer: _ndkConfig.eventSigner,
);
follows = Follows(
requests: requests,
cacheManager: _ndkConfig.cache,
broadcast: broadcast,
signer: _ndkConfig.eventSigner,
);
metadatas = Metadatas(
requests: requests,
cacheManager: _ndkConfig.cache,
broadcast: broadcast,
signer: _ndkConfig.eventSigner,
);
userRelayLists = UserRelayLists(
requests: requests,
cacheManager: _ndkConfig.cache,
broadcast: broadcast,
signer: _ndkConfig.eventSigner,
);
lists = Lists(
requests: requests,
cacheManager: _ndkConfig.cache,
broadcast: broadcast,
eventSigner: _ndkConfig.eventSigner,
);
relaySets = RelaySets(
cacheManager: _ndkConfig.cache,
userRelayLists: userRelayLists,
relayManager: relayManager,
blockedRelays: _globalState.blockedRelays,
);
verifyNip05 = VerifyNip05(
database: _ndkConfig.cache,
nip05Repository: nip05repository,
);
nwc = Nwc(requests: requests, broadcast: broadcast);
}