API • Docs
API / <internal> / CoreManager
TypedEmitter
new CoreManager(
options):CoreManager
• options
• options.autoDownload: undefined | boolean = true
Immediately start downloading cores - should only be set to false for tests
• options.db: BetterSQLite3Database<Record<string, never>, any>
Drizzle better-sqlite3 database instance
• options.encryptionKeys: undefined | Partial<Record<"auth" | "config" | "data" | "blobIndex" | "blob", 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
TypedEmitter.constructor
getcreatorCore():Core
getcreatorCoreRecord():CoreRecord
getdeviceId():string
string
getstaticnamespaces(): readonly ["auth","config","data","blobIndex","blob"]
readonly ["auth", "config", "data", "blobIndex", "blob"]
[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
• stream: any
ReplicationStream
addCore(
key,namespace):CoreRecord
Add a core to the manager (will be persisted across restarts)
• key: Buffer
32-byte public key of core to add
• namespace: "auth" | "config" | "data" | "blobIndex" | "blob"
close():
Promise<void>
Close all open cores and end any replication streams TODO: gracefully close replication streams
Promise<void>
deleteOthersData(
namespace):Promise<void>
• namespace: "config" | "data" | "blobIndex" | "blob"
Promise<void>
getCoreByDiscoveryKey(
discoveryKey):undefined|CoreRecord
Get a core by its discovery key
• discoveryKey: Buffer
undefined | CoreRecord
getCoreByKey(
key):undefined|Core
Get a core by its public key
• key: Buffer
undefined | Core
getCores(
namespace):CoreRecord[]
Get an array of all cores in the given namespace
• namespace: "auth" | "config" | "data" | "blobIndex" | "blob"
getWriterCore(
namespace):CoreRecord
Get the writer core for the given namespace
• namespace: "auth" | "config" | "data" | "blobIndex" | "blob"
ready():
Promise<void>
Resolves when all cores have finished loading
Promise<void>
sendDownloadIntents(
blobFilter,peer):void
• blobFilter: null | _RequireAtLeastOne<object, "photo" | "video" | "audio">
• peer: HypercorePeer
void