Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
EmiM committed Nov 20, 2023
1 parent 97a5652 commit 09076fb
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ export class ConnectionsManagerService extends EventEmitter implements OnModuleI
this.logger('launchCommunityFromStorage')

const community: InitCommunityPayload = await this.localDbService.get(LocalDBKeys.COMMUNITY)
console.log('launchCommunityFromStorage - community peers', community?.peers)
this.logger('launchCommunityFromStorage - community peers', community?.peers)
if (community) {
const sortedPeers = await this.localDbService.getSortedPeers(community.peers)
console.log('launchCommunityFromStorage - sorted peers', sortedPeers)
this.logger('launchCommunityFromStorage - sorted peers', sortedPeers)
if (sortedPeers.length > 0) {
community.peers = sortedPeers
}
Expand Down Expand Up @@ -589,7 +589,6 @@ export class ConnectionsManagerService extends EventEmitter implements OnModuleI
this.serverIoProvider.io.emit(SocketActionTypes.RESPONSE_FETCH_ALL_DIRECT_MESSAGES, payload)
})
this.storageService.on(StorageEvents.UPDATE_PEERS_LIST, (payload: StorePeerListPayload) => {
// this.libp2pService.emit(Libp2pEvents.UPDATE_KNOWN_PEERS_LIST, payload.peerList)
this.serverIoProvider.io.emit(SocketActionTypes.PEER_LIST, payload)
})
this.storageService.on(StorageEvents.SEND_PUSH_NOTIFICATION, (payload: PushNotificationPayload) => {
Expand All @@ -605,9 +604,8 @@ export class ConnectionsManagerService extends EventEmitter implements OnModuleI
this.storageService.on(
StorageEvents.REPLICATED_CSR,
async (payload: { csrs: string[]; certificates: string[]; id: string }) => {
console.log(`On ${StorageEvents.REPLICATED_CSR}`)
this.logger(`Storage - ${StorageEvents.REPLICATED_CSR}`)
this.libp2pService.emit(Libp2pEvents.DIAL_PEERS, await getLibp2pAddressesFromCsrs(payload.csrs))
console.log(`Storage - ${StorageEvents.REPLICATED_CSR}`)
this.serverIoProvider.io.emit(SocketActionTypes.RESPONSE_GET_CSRS, { csrs: payload.csrs })
this.registrationService.emit(RegistrationEvents.REGISTER_USER_CERTIFICATE, payload)
}
Expand Down
1 change: 0 additions & 1 deletion packages/backend/src/nest/libp2p/libp2p.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export enum Libp2pEvents {
PEER_DISCONNECTED = 'peerDisconnected',
NETWORK_STATS = 'networkStats',
DIAL_PEERS = 'dialPeers',
// UPDATE_KNOWN_PEERS_LIST = 'updateKnownPeersList',
}

export interface Libp2pNodeParams {
Expand Down
3 changes: 0 additions & 3 deletions packages/backend/src/nest/libp2p/process-in-chunks.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export class ProcessInChunksService<T> extends EventEmitter {
this.data = data
this.processItem = processItem
this.chunkSize = chunkSize
// this.isActive = true
}

updateData(items: T[]) {
Expand All @@ -26,7 +25,6 @@ export class ProcessInChunksService<T> extends EventEmitter {
}

public async processOneItem() {
// if (!this.isActive) return
const toProcess = this.data.shift()
if (toProcess) {
try {
Expand All @@ -42,7 +40,6 @@ export class ProcessInChunksService<T> extends EventEmitter {
}

public async process() {
// this.isActive = true
this.logger(`Processing ${this.data.length} items`)
for (let i = 0; i < this.chunkSize; i++) {
// Do not wait for this promise as items should be processed simultineously
Expand Down
1 change: 0 additions & 1 deletion packages/backend/src/nest/local-db/local-db.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export class LocalDbService {
}

public async getSortedPeers(peers: string[] = []): Promise<string[]> {
console.log('getSortedPeers peers got', peers)
const peersStats = (await this.get(LocalDBKeys.PEERS)) || {}
const stats: NetworkStats[] = Object.values(peersStats)
return filterAndSortPeers(peers, stats)
Expand Down
4 changes: 0 additions & 4 deletions packages/backend/src/nest/storage/storage.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,12 +337,8 @@ export class StorageService extends EventEmitter {
const allUsers = this.getAllUsers()
const registeredUsers = this.getAllRegisteredUsers()
const peers = [...new Set(await getUsersAddresses(allUsers.concat(registeredUsers)))]
console.log('updatePeersList, peers count:', peers.length)
console.log('STORATE peers', peers)

const community: InitCommunityPayload = await this.localDbService.get(LocalDBKeys.COMMUNITY)
const sortedPeers = await this.localDbService.getSortedPeers(peers)
console.log('STORAGE sortedPeers', sortedPeers)
if (sortedPeers.length > 0) {
community.peers = sortedPeers
await this.localDbService.put(LocalDBKeys.COMMUNITY, community)
Expand Down

0 comments on commit 09076fb

Please sign in to comment.