Skip to content

Commit

Permalink
refactor: clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
alanshaw committed Nov 20, 2024
1 parent 9563857 commit 9df1c53
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions upload-api/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,16 @@ const SAMPLE_SIZE = 1

const codes = [dagPBCode, rawCode]

/** @param {number} max */
const randomInt = max => Math.floor(Math.random() * max)
const randomCodec = () => codes[Math.floor(Math.random() * codes.length)]

const randomCodec = () => codes[randomInt(codes.length)]
const randomDID = async () => (await ed25519.generate()).did()

const randomLink = async () => {
const bytes = webcrypto.getRandomValues(new Uint8Array(256))
const digest = await sha256.digest(bytes)
return Link.create(randomCodec(), digest)
}

const randomDID = async () => {
const signer = await ed25519.generate()
return signer.did()
}

/**
* Get a random sample of registered upload root CIDs. Currently filtered to
* codecs that can be served natively by an IPFS gateway (raw and dag-pb).
Expand Down

0 comments on commit 9df1c53

Please sign in to comment.