Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

blockstore-core

Package Overview
Dependencies
Maintainers
2
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blockstore-core - npm Package Compare versions

Comparing version 4.4.0 to 4.4.1

14

dist/src/identity.d.ts
import { BaseBlockstore } from './base.js';
import type { Pair } from 'interface-blockstore';
import type { Await, AwaitIterable } from 'interface-store';
import type { Blockstore, Pair } from 'interface-blockstore';
import type { AbortOptions, Await, AwaitIterable } from 'interface-store';
import type { CID } from 'multiformats/cid';
export declare class IdentityBlockstore extends BaseBlockstore {
put(key: CID): CID;
private readonly child?;
constructor(child?: Blockstore);
put(key: CID, block: Uint8Array): Await<CID>;
get(key: CID): Await<Uint8Array>;
has(key: CID): boolean;
delete(): void;
getAll(): AwaitIterable<Pair>;
has(key: CID): Await<boolean>;
delete(key: CID): Await<void>;
getAll(options?: AbortOptions): AwaitIterable<Pair>;
}
//# sourceMappingURL=identity.d.ts.map
import { BaseBlockstore } from './base.js';
import * as Errors from './errors.js';
import { Errors } from './index.js';
// https://github.com/multiformats/multicodec/blob/d06fc6194710e8909bac64273c43f16b56ca4c34/table.csv#L2
const IDENTITY_CODEC = 0x00;
export class IdentityBlockstore extends BaseBlockstore {
put(key) {
return key;
child;
constructor(child) {
super();
this.child = child;
}
put(key, block) {
if (key.multihash.code === IDENTITY_CODEC) {
return key;
}
if (this.child == null) {
return key;
}
return this.child.put(key, block);
}
get(key) {
if (key.code === IDENTITY_CODEC) {
if (key.multihash.code === IDENTITY_CODEC) {
return key.multihash.digest;
}
throw Errors.notFoundError();
if (this.child == null) {
throw Errors.notFoundError();
}
return this.child.get(key);
}
has(key) {
return key.code === IDENTITY_CODEC;
if (key.multihash.code === IDENTITY_CODEC) {
return true;
}
if (this.child == null) {
return false;
}
return this.child.has(key);
}
delete() {
delete(key) {
if (key.code === IDENTITY_CODEC) {
return;
}
if (this.child != null) {
return this.child.delete(key);
}
}
*getAll() {
getAll(options) {
if (this.child != null) {
return this.child.getAll(options);
}
return [];
}
}
//# sourceMappingURL=identity.js.map
{
"name": "blockstore-core",
"version": "4.4.0",
"version": "4.4.1",
"description": "Contains various implementations of the API contract described in interface-blockstore",

@@ -113,4 +113,5 @@ "author": "Alex Potsides <alex.potsides@protocol.ai>",

"interface-blockstore-tests": "^6.0.0",
"it-all": "^3.0.4",
"uint8arrays": "^5.0.2"
}
}

@@ -12,2 +12,17 @@ # blockstore-core

<!--
!IMPORTANT!
Everything in this README between "# About" and "# Install" is automatically
generated and will be overwritten the next time the doc generator is run.
To make changes to this section, please update the @packageDocumentation section
of src/index.js or src/index.ts
To experiment with formatting, please run "npm run docs" from the root of this
repo and examine the changes made.
-->
Various Blockstore implementations are available.

@@ -14,0 +29,0 @@

import { BaseBlockstore } from './base.js'
import * as Errors from './errors.js'
import type { Pair } from 'interface-blockstore'
import type { Await, AwaitIterable } from 'interface-store'
import { Errors } from './index.js'
import type { Blockstore, Pair } from 'interface-blockstore'
import type { AbortOptions, Await, AwaitIterable } from 'interface-store'
import type { CID } from 'multiformats/cid'

@@ -11,25 +11,63 @@

export class IdentityBlockstore extends BaseBlockstore {
put (key: CID): CID {
return key
private readonly child?: Blockstore
constructor (child?: Blockstore) {
super()
this.child = child
}
put (key: CID, block: Uint8Array): Await<CID> {
if (key.multihash.code === IDENTITY_CODEC) {
return key
}
if (this.child == null) {
return key
}
return this.child.put(key, block)
}
get (key: CID): Await<Uint8Array> {
if (key.code === IDENTITY_CODEC) {
if (key.multihash.code === IDENTITY_CODEC) {
return key.multihash.digest
}
throw Errors.notFoundError()
if (this.child == null) {
throw Errors.notFoundError()
}
return this.child.get(key)
}
has (key: CID): boolean {
return key.code === IDENTITY_CODEC
has (key: CID): Await<boolean> {
if (key.multihash.code === IDENTITY_CODEC) {
return true
}
if (this.child == null) {
return false
}
return this.child.has(key)
}
delete (): void {
delete (key: CID): Await<void> {
if (key.code === IDENTITY_CODEC) {
return
}
if (this.child != null) {
return this.child.delete(key)
}
}
* getAll (): AwaitIterable<Pair> {
getAll (options?: AbortOptions): AwaitIterable<Pair> {
if (this.child != null) {
return this.child.getAll(options)
}
return []
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc