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 this.ndkConfig,
required this.globalState,
}) {
relayManager = RelayManager(
nostrTransportFactory: _webSocketNostrTransportFactory,
bootstrapRelays: ndkConfig.bootstrapRelays,
globalState: globalState,
);
switch (ndkConfig.engine) {
case NdkEngine.RELAY_SETS:
engine = RelaySetsEngine(
cacheManager: ndkConfig.cache,
globalState: globalState,
relayManager: relayManager,
);
break;
case NdkEngine.JIT:
engine = JitEngine(
eventSigner: ndkConfig.eventSigner,
cache: ndkConfig.cache,
ignoreRelays: ndkConfig.ignoreRelays,
seedRelays: ndkConfig.bootstrapRelays,
globalState: globalState,
);
break;
default:
throw UnimplementedError("Unknown engine");
}
cacheWrite = CacheWrite(ndkConfig.cache);
cacheRead = CacheRead(ndkConfig.cache);
requests = Requests(
globalState: globalState,
cacheRead: cacheRead,
cacheWrite: cacheWrite,
networkEngine: engine,
eventVerifier: ndkConfig.eventVerifier,
);
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,
relayManager: relayManager,
);
lists = Lists(
requests: requests,
cacheManager: ndkConfig.cache,
relayManager: relayManager,
);
relaySets = RelaySets(
cacheManager: ndkConfig.cache,
relayManager: relayManager,
userRelayLists: userRelayLists,
);
}