-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sometimes it's useful to not store anything, for example calculating the CID of a datastructure without actually storing any of the data.
- Loading branch information
1 parent
61f56da
commit 6074f0f
Showing
6 changed files
with
96 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
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 type { CID } from 'multiformats/cid' | ||
|
||
export class BlackHoleBlockstore extends BaseBlockstore { | ||
put (key: CID): Await<CID> { | ||
return key | ||
} | ||
|
||
get (): Await<Uint8Array> { | ||
throw Errors.notFoundError() | ||
} | ||
|
||
has (): Await<boolean> { | ||
return false | ||
} | ||
|
||
async delete (): Promise<void> { | ||
|
||
} | ||
|
||
async * getAll (): AwaitIterable<Pair> { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { BaseDatastore } from './base.js' | ||
import * as Errors from './errors.js' | ||
import type { Pair } from 'interface-datastore' | ||
import type { Key } from 'interface-datastore/key' | ||
import type { Await, AwaitIterable } from 'interface-store' | ||
|
||
export class BlackHoleDatastore extends BaseDatastore { | ||
put (key: Key): Await<Key> { | ||
return key | ||
} | ||
|
||
get (): Await<Uint8Array> { | ||
throw Errors.notFoundError() | ||
} | ||
|
||
has (key: Key): Await<boolean> { | ||
return false | ||
} | ||
|
||
delete (key: Key): Await<void> { | ||
|
||
} | ||
|
||
* _all (): AwaitIterable<Pair> { | ||
|
||
} | ||
|
||
* _allKeys (): AwaitIterable<Key> { | ||
|
||
} | ||
} |