-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: calculate car cid and size during validation (#137)
Update car key to `${carCid}/${carCid}.car`, so we can start writing them to carpark. Calculate the sha256 of the car bytes from the stream as we produce the linkdex report to determine if the car is complete / valid Log total bytes per CAR as `carSize`. Use this to calculate the throughput in loki. Needed as we wont be able to use the size of the bucket once we start writing to the shared carpark. Fixes #136 TODO - [ ] update the production and staging env to write to carpark bucket. License: MIT --------- Signed-off-by: Oli Evans <oli@protocol.ai>
- Loading branch information
Showing
4 changed files
with
72 additions
and
30 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { packToBlob } from 'ipfs-car/pack/blob' | ||
import { checkCar } from '../lib/car.js' | ||
import test from 'ava' | ||
|
||
test('checkCar', async t => { | ||
const { car } = await packToBlob({ input: 'hello world', wrapWithDirectory: false }) | ||
const { carCid, carSize, report } = await checkCar(car.stream()) | ||
t.is(carCid.toString(), 'bagbaierao5e6fdcp4p3iyafmbcxudqoe63qcoxegxwpivz5zirw2pulgg4ia') | ||
t.is(report.blocksIndexed, 1) | ||
t.is(report.undecodeable, 0) | ||
t.is(report.uniqueCids, 1) | ||
t.is(report.structure, 'Complete') | ||
t.is(carSize, 107) | ||
}) |