View sns2s3.js
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
/** | |
* Extract an S3Event from the passed SNSEvent. | |
* @param {import('aws-lambda').SNSEvent} snsEvent | |
* @returns {import('aws-lambda').S3Event} | |
*/ | |
function toS3Event (snsEvent) { | |
const s3Event = { Records: [] } | |
for (const snsRec of snsEvent.Records) { | |
try { | |
for (const s3Rec of JSON.parse(snsRec.Sns.Message).Records || []) { |
View filter.txt
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
review-requested:alanshaw |
View dagChecker.js
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
// Lambda index CAR //////////////////////////////////////////////////////////// | |
const blocks = Set<CID>() | |
const links = Set<CID>() | |
const car = readCar(path) | |
for (const block in car) { | |
blocks.add(block.cid) | |
getLinks(block).forEach(cid => links.add(cid)) | |
} |
View custom-bs-path.mjs
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
import { NFTStorage } from 'nft.storage' | |
import { getFilesFromPath } from 'files-from-path' | |
import { FsBlockStore as Blockstore } from 'ipfs-car/blockstore/fs' | |
import Path from 'path' | |
const token = 'YOUR_API_TOKEN' | |
// /////////////////////////////////////////////////////////////////////////// | |
// Save DAG to a custom location by changing this path... | |
const bsPath = './blockstore' |
View setulimit.sh
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
sudo sysctl kern.maxfilesperproc=256 |
View sample.mjs
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
/** | |
* Create IPFS unixfs directories of random CIDs from the data source. CIDs are | |
* grouped by DAG size: | |
* 0-1MB | |
* 1MB-5MB | |
* 5MB-25MB | |
* 25MB-100MB | |
* 100MB-500MB | |
* 500MB-1GB | |
* 1GB-10GB |
View web3file.ts
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
import path from 'path' | |
type ImportCandidate = x|y|z|{ path: string, content: x|y|z } | |
type UnixFsEntry = { path: string, content: AsyncIterable<Uint8Array> } | |
// extends Blob? | |
class Web3File extends Blob { | |
constructor (filename: string, content: AsyncIterable<Uint8Array>, options?: Web3FileOpts) | |
// Generate from content? |
View deadline.js
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
const deadline = async function * (source, deadineMs, onDeadline) { | |
class DeadlineError extends Error {} | |
while (true) { | |
let timeoutID | |
try { | |
const next = await Promise.race([ | |
new Promise((resolve, reject) => { | |
timeoutID = setTimeout(() => reject(new DeadlineError()), deadineMs) | |
}), | |
source.next() |
View address.ts
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
import addr, { Address, newAddress } from '@glif/filecoin-address' | |
import { blake2b } from 'blakejs' | |
import varint from 'varint' | |
/** | |
* PayloadHashLength defines the hash length taken over addresses using the Actor and SECP256K1 protocols. | |
*/ | |
export const payloadHashLength = 20 | |
function addressHash (ingest: Uint8Array): Uint8Array { |
View balances-to-json.js
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
// 1. Install deps with `npm i csv-parse @glif/filecoin-number` | |
// 2. Drop `balances.baseline.clean.out` and `balances.claus.clean.out` into the CWD | |
// 3. Run `node balances-to-json.js` | |
// 4. It'll create `balances.baseline.json` and `balances.claus.json` and `actors.json` in the CWD | |
const fs = require('fs') | |
const parse = require('csv-parse') | |
const { FilecoinNumber } = require('@glif/filecoin-number') | |
async function main () { |
NewerOlder