refactor: move S5NodeConfig to types and make network optional

This commit is contained in:
Derrick Hammer 2023-08-31 10:58:10 -04:00
parent bbda50ddfb
commit 6e74ef6d8f
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 15 additions and 14 deletions

View File

@ -1,6 +1,6 @@
import { Multihash } from "./multihash.js"; import { Multihash } from "./multihash.js";
import NodeId from "./nodeId.js"; import NodeId from "./nodeId.js";
import { Logger, S5Config, S5Services } from "./types.js"; import { Logger, S5Config, S5NodeConfig, S5Services } from "./types.js";
import Unpacker from "./serialization/unpack.js"; import Unpacker from "./serialization/unpack.js";
import Packer from "./serialization/pack.js"; import Packer from "./serialization/pack.js";
import StorageLocation from "./storage.js"; import StorageLocation from "./storage.js";
@ -26,18 +26,6 @@ const DEFAULT_LOGGER = {
}, },
}; };
export interface S5NodeConfig {
p2p?: {
network: string;
peers?: {
initial?: string[];
};
};
keyPair: KeyPairEd25519;
db: AbstractLevel<Uint8Array, string, Uint8Array>;
logger?: Logger;
}
export class S5Node { export class S5Node {
private _nodeConfig: S5NodeConfig; private _nodeConfig: S5NodeConfig;

View File

@ -51,7 +51,7 @@ export interface S5Services {
export interface S5Config { export interface S5Config {
p2p?: { p2p?: {
network: string; network?: string;
peers?: { peers?: {
initial?: string[]; initial?: string[];
}; };
@ -62,6 +62,19 @@ export interface S5Config {
cacheDb: AbstractLevel<Uint8Array, string, Uint8Array>; cacheDb: AbstractLevel<Uint8Array, string, Uint8Array>;
services: S5Services; services: S5Services;
} }
export interface S5NodeConfig {
p2p?: {
network?: string;
peers?: {
initial?: string[];
};
};
keyPair: KeyPairEd25519;
db: AbstractLevel<Uint8Array, string, Uint8Array>;
logger?: Logger;
}
export interface SignedMessage { export interface SignedMessage {
nodeId: NodeId; nodeId: NodeId;
message: Uint8Array; message: Uint8Array;