Comparing version 2.2.0 to 3.0.0
@@ -1,3 +0,6 @@ | ||
/** @typedef { 'Complete' | 'Partial' | 'Unknown' } DagStructure */ | ||
/** | ||
* @typedef { 'Complete' | 'Partial' | 'Unknown' } DagStructure | ||
* @typedef {import('multiformats').UnknownLink} UnknownLink | ||
*/ | ||
/** | ||
* @typedef {Object} Report | ||
@@ -33,5 +36,5 @@ * @property {DagStructure} structure - Are there any Linked CIDs that are not present in the set of blocks | ||
* Map block CID to the set of CIDs it links to | ||
* @type {Map<string, Set<string>>} | ||
* */ | ||
idx: Map<string, Set<string>>; | ||
* @type {Map<UnknownLink, Set<UnknownLink>>} | ||
*/ | ||
idx: Map<UnknownLink, Set<UnknownLink>>; | ||
blocksIndexed: number; | ||
@@ -86,2 +89,3 @@ undecodable: number; | ||
export type DagStructure = 'Complete' | 'Partial' | 'Unknown'; | ||
export type UnknownLink = import('multiformats').UnknownLink; | ||
export type Report = { | ||
@@ -88,0 +92,0 @@ /** |
22
index.js
import { CarBlockIterator } from '@ipld/car/iterator' | ||
import { Map as LinkMap } from 'lnmap' | ||
import { Set as LinkSet } from 'lnset' | ||
import { maybeDecode } from './decode.js' | ||
/** @typedef { 'Complete' | 'Partial' | 'Unknown' } DagStructure */ | ||
/** | ||
* @typedef { 'Complete' | 'Partial' | 'Unknown' } DagStructure | ||
* @typedef {import('multiformats').UnknownLink} UnknownLink | ||
*/ | ||
@@ -55,5 +60,5 @@ /** | ||
* Map block CID to the set of CIDs it links to | ||
* @type {Map<string, Set<string>>} | ||
* */ | ||
this.idx = new Map() | ||
* @type {Map<UnknownLink, Set<UnknownLink>>} | ||
*/ | ||
this.idx = new LinkMap() | ||
this.blocksIndexed = 0 | ||
@@ -107,9 +112,8 @@ this.undecodable = 0 | ||
_index (block) { | ||
const key = block.cid.toString() | ||
if (this.idx.has(key)) { | ||
if (this.idx.has(block.cid)) { | ||
return // already indexed this block | ||
} | ||
const targets = new Set() | ||
const targets = new LinkSet() | ||
for (const [, targetCid] of block.links()) { | ||
targets.add(targetCid.toString()) | ||
targets.add(targetCid) | ||
if (targetCid.multihash.code === 0x0) { | ||
@@ -119,3 +123,3 @@ this._decodeAndIndexIdentityCidLink(targetCid) | ||
} | ||
this.idx.set(key, targets) | ||
this.idx.set(block.cid, targets) | ||
} | ||
@@ -122,0 +126,0 @@ |
{ | ||
"name": "linkdex", | ||
"version": "2.2.0", | ||
"version": "3.0.0", | ||
"type": "module", | ||
@@ -43,2 +43,4 @@ "description": "An index mapping block CID to linked block CID.", | ||
"@web3-storage/car-block-validator": "^1.2.0", | ||
"lnmap": "^1.0.1", | ||
"lnset": "^1.2.0", | ||
"multiformats": "^11.0.2", | ||
@@ -45,0 +47,0 @@ "sade": "^1.8.1" |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24011
511
9
+ Addedlnmap@^1.0.1
+ Addedlnset@^1.2.0
+ Addedlnmap@1.0.1(transitive)
+ Addedlnset@1.2.0(transitive)
+ Addedmultiformats@12.1.3(transitive)