remove net global state
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import type {Unsubscriber} from "svelte/store"
|
||||
import {call} from "@welshman/lib"
|
||||
import {Pool, Socket, Tracker, Repository, WrapManager, defaultSocketPolicies} from "@welshman/net"
|
||||
import type {AdapterContext, AdapterFactory, SocketPolicy} from "@welshman/net"
|
||||
import type {NetContext, AdapterFactory, SocketPolicy} from "@welshman/net"
|
||||
import type {User} from "./user.js"
|
||||
import type {ClientPolicy} from "./policies.js"
|
||||
|
||||
@@ -24,7 +24,7 @@ export interface IClient {
|
||||
user?: User
|
||||
config: ClientConfig
|
||||
use: <T>(Ctor: new (ctx: IClient) => T) => T
|
||||
netContext: AdapterContext
|
||||
netContext: NetContext
|
||||
pool: Pool
|
||||
tracker: Tracker
|
||||
repository: Repository
|
||||
@@ -40,7 +40,7 @@ export interface IClient {
|
||||
export class Client implements IClient {
|
||||
user?: User
|
||||
config: ClientConfig
|
||||
netContext: AdapterContext
|
||||
netContext: NetContext
|
||||
pool: Pool
|
||||
tracker: Tracker
|
||||
repository: Repository
|
||||
|
||||
@@ -18,7 +18,7 @@ export class GiftWraps {
|
||||
|
||||
constructor(readonly ctx: IClient) {
|
||||
this.queue = new TaskQueue<TrustedEvent>({
|
||||
batchSize: 5,
|
||||
batchSize: 50,
|
||||
batchDelay: 30,
|
||||
processItem: async (wrap: TrustedEvent) => {
|
||||
const signer = this.ctx.user?.signer
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import type {Unsubscriber} from "svelte/store"
|
||||
import {on} from "@welshman/lib"
|
||||
import {WRAP, isDVMKind, isEphemeralKind} from "@welshman/util"
|
||||
import {WRAP, isDVMKind, isEphemeralKind, verifyEvent} from "@welshman/util"
|
||||
import type {TrustedEvent} from "@welshman/util"
|
||||
import {SocketEvent, netContext, isRelayEvent} from "@welshman/net"
|
||||
import {SocketEvent, isRelayEvent} from "@welshman/net"
|
||||
import type {RelayMessage} from "@welshman/net"
|
||||
import type {IClient} from "./client.js"
|
||||
import {RelayStats} from "./relayStats.js"
|
||||
@@ -30,7 +30,7 @@ export const clientPolicyIngest: ClientPolicy = client =>
|
||||
const event = message[2]
|
||||
|
||||
if (isDVMKind(event.kind) || isEphemeralKind(event.kind)) return
|
||||
if (!netContext.isEventValid(event, socket.url)) return
|
||||
if (!verifyEvent(event)) return
|
||||
|
||||
client.tracker.track(event.id, socket.url)
|
||||
client.repository.publish(event)
|
||||
|
||||
Reference in New Issue
Block a user