Skip to content

Latest commit

 

History

History
258 lines (131 loc) · 4.43 KB

CoreManager.md

File metadata and controls

258 lines (131 loc) · 4.43 KB

APIDocs


API / <internal> / CoreManager

Class: CoreManager

Extends

  • TypedEmitter

Constructors

new CoreManager()

new CoreManager(options): CoreManager

Parameters

options

options.autoDownload: undefined | boolean = true

Immediately start downloading cores - should only be set to false for tests

options.db: BetterSQLite3Database<Record<string, never>>

Drizzle better-sqlite3 database instance

options.encryptionKeys: undefined | Partial<Record<"blob" | "auth" | "config" | "data" | "blobIndex", Buffer>> = {}

Encryption keys for each namespace

options.keyManager: KeyManager

mapeo/crypto KeyManager instance

options.logger: undefined | Logger

options.projectKey: Buffer

32-byte public key of the project creator core

options.projectSecretKey: undefined | Buffer

32-byte secret key of the project creator core

options.storage: HypercoreStorage

Folder to store all hypercore data

Returns

CoreManager

Overrides

TypedEmitter.constructor

Accessors

creatorCore

get creatorCore(): Core

Returns

Core


creatorCoreRecord

get creatorCoreRecord(): CoreRecord

Returns

CoreRecord


deviceId

get deviceId(): string

Returns

string


namespaces

get static namespaces(): readonly ["auth", "config", "data", "blobIndex", "blob"]

Returns

readonly ["auth", "config", "data", "blobIndex", "blob"]

Methods

[kCoreManagerReplicate]()

[kCoreManagerReplicate](stream): ReplicationStream

ONLY FOR TESTING Replicate all cores in core manager

NB: Remote peers need to be manually added when unit testing core manager without the Sync API

Parameters

stream: any

Returns

ReplicationStream


addCore()

addCore(key, namespace): CoreRecord

Add a core to the manager (will be persisted across restarts)

Parameters

key: Buffer

32-byte public key of core to add

namespace: "blob" | "auth" | "config" | "data" | "blobIndex"

Returns

CoreRecord


close()

close(): Promise<void>

Close all open cores and end any replication streams TODO: gracefully close replication streams

Returns

Promise<void>


deleteOthersData()

deleteOthersData(namespace): Promise<void>

Parameters

namespace: "blob" | "config" | "data" | "blobIndex"

Returns

Promise<void>


getCoreByDiscoveryKey()

getCoreByDiscoveryKey(discoveryKey): undefined | CoreRecord

Get a core by its discovery key

Parameters

discoveryKey: Buffer

Returns

undefined | CoreRecord


getCoreByKey()

getCoreByKey(key): undefined | Core

Get a core by its public key

Parameters

key: Buffer

Returns

undefined | Core


getCores()

getCores(namespace): CoreRecord[]

Get an array of all cores in the given namespace

Parameters

namespace: "blob" | "auth" | "config" | "data" | "blobIndex"

Returns

CoreRecord[]


getWriterCore()

getWriterCore(namespace): CoreRecord

Get the writer core for the given namespace

Parameters

namespace: "blob" | "auth" | "config" | "data" | "blobIndex"

Returns

CoreRecord


ready()

ready(): Promise<void>

Resolves when all cores have finished loading

Returns

Promise<void>


sendDownloadIntents()

sendDownloadIntents(blobFilter, peer): void

Parameters

blobFilter: BlobFilter

peer: HypercorePeer

Returns

void