Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const file = Unixfs.default('file');
for (let i = 0; i < results.length; i++) {
file.addBlockSize(results[i].size);
}
const indexFile = new DAGNode(file.marshal());
for (let i = 0; i < results.length; i++) {
indexFile.addLink({
Hash: results[i].hash,
Size: results[i].size
});
}
const indexFileResponse = await this.ipfs.dag.put(indexFile, WarpController.DEFAULT_NODE_TYPE);
const directory = Unixfs.default('directory');
for (let i = 0; i < results.length; i++) {
directory.addBlockSize(results[i].size);
}
directory.addBlockSize(file.fileSize());
const directoryNode = new DAGNode(directory.marshal());
for (let i = 0; i < results.length; i++) {
console.log(results[i]);
directoryNode.addLink({
Name: `file${i}`,
Hash: results[i].hash,
Size: results[i].size
});
}
directoryNode.addLink({
async addDBToIPFS(table: Dexie.Table) {
const results = await this.ipfsAddRows(await table.toArray());
const file = Unixfs.default('file');
for (let i = 0; i < results.length; i++) {
file.addBlockSize(results[i].size);
}
const indexFile = new DAGNode(file.marshal());
for (let i = 0; i < results.length; i++) {
indexFile.addLink({
Hash: results[i].hash,
Size: results[i].size
});
}
const indexFileResponse = await this.ipfs.dag.put(indexFile, WarpController.DEFAULT_NODE_TYPE);
const directory = Unixfs.default('directory');
for (let i = 0; i < results.length; i++) {
async createAllCheckpoints() {
const otherDir = new DAGNode(Unixfs.default('directory').marshal());
const versionFile = await this.ipfs.add({
content: Buffer.from(WARPSYNC_VERSION),
});
otherDir.addLink({
Name: 'VERSION',
Hash: versionFile[0].hash,
Size: 1,
});
for(const table of this.db.databasesToSync()) {
const r = await this.addDBToIPFS(table);
otherDir.addLink(r);
}
const d = await this.ipfs.dag.put(otherDir, WarpController.DEFAULT_NODE_TYPE);
return d.toString();