refactor: message id

This commit is contained in:
手瓜一十雪
2024-07-23 15:10:39 +08:00
parent d4913a03c3
commit 2e850e9d17
3 changed files with 33 additions and 24 deletions

View File

@@ -1,5 +1,6 @@
import { Peer } from '@/core';
import crypto, { randomInt, randomUUID } from 'crypto';
import { logError } from './log';
class LimitedHashTable<K, V> {
private keyToValue: Map<K, V> = new Map();
@@ -75,7 +76,7 @@ class MessageUniqueWrapper {
const hash = crypto.createHash('sha1').update(key);
const shortId = parseInt(hash.digest('hex').slice(0, 8), 16);
const isExist = this.msgIdMap.getKey(shortId);
console.log(`${peer.peerUid} ${msgId} ------- ${shortId}`);
//console.log(`${peer.peerUid} ${msgId} ------- ${shortId}`);
if (isExist && isExist === msgId) {
return shortId;
}