Merge pull request #815 from shocknet/sharding-fix

Sharding fix
This commit is contained in:
Justin (shocknet) 2025-06-07 12:49:19 -04:00 committed by GitHub
commit e11c2b35f0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View file

@ -14,7 +14,7 @@ const { getConversationKey: getConversationKeyV2 } = utils
const handledEvents: string[] = [] // TODO: - big memory leak here, add TTL
type AppInfo = { appId: string, publicKey: string, privateKey: string, name: string }
type ClientInfo = { clientId: string, publicKey: string, privateKey: string, name: string }
type SendDataContent = { type: "content", content: string, pub: string, index?: number, totalShards?: number, shardsId?: string }
type SendDataContent = { type: "content", content: string, pub: string }
type SendDataEvent = { type: "event", event: UnsignedEvent, encrypt?: { toPub: string } }
export type SendData = SendDataContent | SendDataEvent
export type SendInitiator = { type: 'app', appId: string } | { type: 'client', clientId: string }
@ -232,7 +232,7 @@ export default class Handler {
if (parts.length > 1) {
const shardsId = crypto.randomBytes(16).toString('hex')
const totalShards = parts.length
const ues = await Promise.all(parts.map((part, index) => this.handleSendDataContent({ ...data, content: part, index, totalShards, shardsId }, keys)))
const ues = await Promise.all(parts.map((part, index) => this.handleSendDataContent({ ...data, content: JSON.stringify({ part, index, totalShards, shardsId }) }, keys)))
return ues
}
return [await this.handleSendDataContent(data, keys)]

View file

@ -10,7 +10,7 @@ const getEnvOrDefault = (name: string, defaultValue: string): string => {
export const LoadNosrtSettingsFromEnv = (test = false) => {
const relaysEnv = getEnvOrDefault("NOSTR_RELAYS", "wss://relay.lightning.pub");
const maxEventContentLength = EnvCanBeInteger("NOSTR_MAX_EVENT_CONTENT_LENGTH", 45000)
const maxEventContentLength = EnvCanBeInteger("NOSTR_MAX_EVENT_CONTENT_LENGTH", 40000)
return {
relays: relaysEnv.split(' '),
maxEventContentLength