MCPcopy Create free account
hub / github.com/cloudflare/computer / pushOneWrite

Function pushOneWrite

script/computerd-soak.mjs:231–257  ·  view source on GitHub ↗
(stub, i, bytes)

Source from the content-addressed store, hash-verified

229// path silenced the outbound loop and A never saw any of B's
230// writes.
231async function pushOneWrite(stub, i, bytes) {
232 const hash = new Uint8Array(await crypto.subtle.digest("SHA-256", bytes));
233 await stub.sync.pushObjects(
234 new ReadableStream({
235 start(c) {
236 c.enqueue({ hash, bytes });
237 c.close();
238 },
239 }),
240 );
241 await stub.sync.push({
242 senderRev: 0,
243 changes: new ReadableStream({
244 start(c) {
245 c.enqueue({
246 kind: "file",
247 path: `/soak_${i}.bin`,
248 mode: 0o644,
249 mtime: Date.now(),
250 size: bytes.byteLength,
251 chunks: [{ hash, size: bytes.byteLength }],
252 });
253 c.close();
254 },
255 }),
256 });
257}
258
259async function main() {
260 if (!DISABLE_FUSE) await ensureImage();

Callers 1

mainFunction · 0.85

Calls 2

pushObjectsMethod · 0.65
pushMethod · 0.65

Tested by

no test coverage detected