Skip to content

Commit

Permalink
remove logs
Browse files Browse the repository at this point in the history
  • Loading branch information
acdibble committed Jun 19, 2024
1 parent 0a06348 commit fef9b00
Showing 1 changed file with 10 additions and 24 deletions.
34 changes: 10 additions & 24 deletions bouncer/shared/utils/substrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,13 @@ const getCachedDisposable = <T extends AsyncDisposable, F extends (...args: any[
}

connections += 1;
console.log({ connections });

return new Proxy(disposable, {
get(target, prop, receiver) {
if (prop === Symbol.asyncDispose) {
console.log({ connections });
return () => {
setTimeout(() => {
if (connections === 0) {
console.log({ connections });

const dispose = Reflect.get(
target,
Symbol.asyncDispose,
Expand Down Expand Up @@ -85,7 +81,6 @@ const getCachedSubstrateApi = (endpoint: string) =>
return new Proxy(apiPromise as unknown as DisposableApiPromise, {
get(target, prop, receiver) {
if (prop === Symbol.asyncDispose) {
console.log('disposing');
return Reflect.get(target, 'disconnect', receiver);
}
if (prop === 'disconnect') {
Expand Down Expand Up @@ -251,8 +246,6 @@ type AbortableObserver<T> = {
event: Promise<Event<T> | null>;
};

let monitor = 0;

/* eslint-disable @typescript-eslint/no-explicit-any */
export function observeEvent<T = any>(eventName: EventName): Observer<T>;
export function observeEvent<T = any>(eventName: EventName, opts: Options<T>): Observer<T>;
Expand All @@ -276,26 +269,19 @@ export function observeEvent<T = any>(
const findEvent = async () => {
await using subscription = await subscribeHeads({ chain, finalized });
const it = observableToIterable(subscription.observable, controller?.signal);
monitor += 1;
console.log({ 'monitoring events': monitor });
try {
for await (const events of it) {
for (const event of events) {
if (
event.name.section.includes(expectedSection) &&
event.name.method.includes(expectedMethod) &&
test(event)
) {
return event as Event<T>;
}
for await (const events of it) {
for (const event of events) {
if (
event.name.section.includes(expectedSection) &&
event.name.method.includes(expectedMethod) &&
test(event)
) {
return event as Event<T>;
}
}

return null;
} finally {
monitor -= 1;
console.log({ 'monitoring events': monitor });
}

return null;
};

if (!controller) return { event: findEvent() } as Observer<T>;
Expand Down

0 comments on commit fef9b00

Please sign in to comment.