Skip to content

Commit

Permalink
fix: rm unused imports
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-pousette committed Nov 1, 2023
1 parent 47577fe commit 89837fe
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 25 deletions.
5 changes: 2 additions & 3 deletions packages/programs/acl/trusted-network/src/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
CanRead,
TransactionContext
} from "@peerbit/document";
import { AppendOptions, Entry } from "@peerbit/log";
import { AppendOptions } from "@peerbit/log";
import { PublicSignKey, getPublicKeyFromPeerId } from "@peerbit/crypto";
import { DeleteOperation } from "@peerbit/document";
import {
Expand All @@ -19,8 +19,7 @@ import {
hasPath,
getFromByTo,
getToByFrom,
getRelation,
AbstractRelation
getRelation
} from "./identity-graph.js";
import { Program } from "@peerbit/program";
import { sha256Base64Sync } from "@peerbit/crypto";
Expand Down
3 changes: 2 additions & 1 deletion packages/programs/data/document/src/document-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from "@dao-xyz/borsh";
import { Change, Entry, EntryType, TrimOptions } from "@peerbit/log";
import { Program, ProgramEvents } from "@peerbit/program";
import { AccessError, DecryptedThing, PublicSignKey } from "@peerbit/crypto";
import { AccessError, DecryptedThing } from "@peerbit/crypto";
import { logger as loggerFn } from "@peerbit/logger";
import { AppendOptions } from "@peerbit/log";
import { CustomEvent } from "@libp2p/interface/events";
Expand All @@ -20,6 +20,7 @@ import {
SharedLogOptions,
SharedAppendOptions
} from "@peerbit/shared-log";

export { Role, Observer, Replicator }; // For convenience (so that consumers does not have to do the import above from shared-log packages)

import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { delay, waitForResolved } from "@peerbit/time";
import { DirectSub } from "@peerbit/pubsub";
import { DirectBlock } from "@peerbit/blocks";
import { getPublicKeyFromPeerId } from "@peerbit/crypto";
import { Observer } from "../role";
import { Observer } from "../role.js";

describe(`leaders`, function () {
let session: TestSession;
Expand Down
12 changes: 6 additions & 6 deletions packages/programs/data/shared-log/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ export class SharedLog<T = Uint8Array> extends Program<
if (v.equals(this.node.identity.publicKey)) {
return;
}
this.handleSubscriptionChange(v, [{ topic: this.topic }], true);
this.handleSubscriptionChange(v, [this.topic], true);
}
);

Expand Down Expand Up @@ -836,13 +836,13 @@ export class SharedLog<T = Uint8Array> extends Program<

async handleSubscriptionChange(
publicKey: PublicSignKey,
changes: { topic: string }[],
changes: string[],
subscribed: boolean
) {
if (subscribed) {
if (this.role instanceof Replicator) {
for (const subscription of changes) {
if (this.log.idString !== subscription.topic) {
if (this.log.idString !== subscription) {
continue;
}
await this.rpc.send(new ResponseRoleMessage(this.role), {
Expand All @@ -855,7 +855,7 @@ export class SharedLog<T = Uint8Array> extends Program<
//if(evt.detail.subscriptions.map((x) => x.topic).includes())
} else {
for (const topic of changes) {
if (this.log.idString !== topic.topic) {
if (this.log.idString !== topic) {
continue;
}
const change = await this.modifyReplicatorsCache(
Expand Down Expand Up @@ -1153,7 +1153,7 @@ export class SharedLog<T = Uint8Array> extends Program<
async _onUnsubscription(evt: CustomEvent<UnsubcriptionEvent>) {
logger.debug(
`Peer disconnected '${evt.detail.from.hashcode()}' from '${JSON.stringify(
evt.detail.unsubscriptions.map((x) => x.topic)
evt.detail.unsubscriptions.map((x) => x)
)}'`
);

Expand All @@ -1167,7 +1167,7 @@ export class SharedLog<T = Uint8Array> extends Program<
async _onSubscription(evt: CustomEvent<SubscriptionEvent>) {
logger.debug(
`New peer '${evt.detail.from.hashcode()}' connected to '${JSON.stringify(
evt.detail.subscriptions.map((x) => x.topic)
evt.detail.subscriptions.map((x) => x)
)}'`
);
return this.handleSubscriptionChange(
Expand Down
14 changes: 4 additions & 10 deletions packages/programs/program/src/__tests__/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import {
} from "@peerbit/crypto";
import { ProgramClient, ProgramHandler } from "../program";
import {
Subscription,
SubscriptionEvent,
UnsubcriptionEvent,
Unsubscription
UnsubcriptionEvent
} from "@peerbit/pubsub-interface";
import { CustomEvent } from "@libp2p/interface/events";

Expand Down Expand Up @@ -87,9 +85,7 @@ export const createPeer = async (
});
dispatchEvent(
new CustomEvent<SubscriptionEvent>("subscribe", {
detail: new SubscriptionEvent(keypair.publicKey, [
new Subscription(topic)
])
detail: new SubscriptionEvent(keypair.publicKey, [topic])
})
);
},
Expand All @@ -108,9 +104,7 @@ export const createPeer = async (
if (ret) {
dispatchEvent(
new CustomEvent<UnsubcriptionEvent>("unsubscribe", {
detail: new UnsubcriptionEvent(keypair.publicKey, [
new Unsubscription(topic)
])
detail: new UnsubcriptionEvent(keypair.publicKey, [topic])
})
);
}
Expand Down Expand Up @@ -144,7 +138,7 @@ export const createPeer = async (
// TODO undefined checks
detail: new SubscriptionEvent(
state.peers.get(hash)!.identity.publicKey!,
[new Subscription(topic)]
[topic]
)
}),
true
Expand Down
1 change: 1 addition & 0 deletions packages/programs/program/src/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { waitFor } from "@peerbit/time";
import { Blocks } from "@peerbit/blocks-interface";
import { PeerId as Libp2pPeerId } from "@libp2p/interface/peer-id";
import {
PubSub,
SubscriptionEvent,
UnsubcriptionEvent
} from "@peerbit/pubsub-interface";
Expand Down
3 changes: 0 additions & 3 deletions packages/programs/rpc/src/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,14 @@ import {
} from "@peerbit/crypto";
import { RequestV0, ResponseV0, RPCMessage } from "./encoding.js";
import { RPCOptions, logger, RPCResponse, PublishOptions } from "./io.js";
import { Address } from "@peerbit/program";
import {
DataEvent,
PubSubData,
PublishOptions as PubSubPublishOptions
} from "@peerbit/pubsub-interface";
import { Program } from "@peerbit/program";
import { DataMessage } from "@peerbit/stream-interface";
import pDefer, { DeferredPromise } from "p-defer";
import { waitFor } from "@peerbit/time";
import { equals } from "uint8arrays";

export type RPCSetupOptions<Q, R> = {
topic: string;
Expand Down
1 change: 0 additions & 1 deletion packages/transport/blocks/src/streams.ts

This file was deleted.

0 comments on commit 89837fe

Please sign in to comment.