Skip to content

Commit

Permalink
m
Browse files Browse the repository at this point in the history
  • Loading branch information
anjor committed Sep 17, 2024
1 parent 1a9a164 commit 3bf2873
Showing 1 changed file with 37 additions and 6 deletions.
43 changes: 37 additions & 6 deletions cmd-car-split.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,25 @@ func newCmd_SplitCar() *cli.Command {
return fmt.Errorf("failed to calculate commitment to cid: %w", err)
}

carFiles = append(carFiles, carFile{name: fmt.Sprintf("epoch-%d-%d.car", epoch, currentFileNum), commP: commCid, payloadCid: sl.(cidlink.Link).Cid, paddedSize: ps, fileSize: currentFileSize})

metadata.CarPieces.CarPieces = append(metadata.CarPieces.CarPieces, carlet.CarFile{Name: currentSubsetInfo.fileName, ContentSize: currentFileSize, HeaderSize: uint64(len(nulRootCarHeader)), CommP: commCid})
carFiles = append(
carFiles,
carFile{
name: fmt.Sprintf("epoch-%d-%d.car", epoch, currentFileNum),
commP: commCid,
payloadCid: sl.(cidlink.Link).Cid,
paddedSize: ps,
fileSize: currentFileSize,
})

metadata.CarPieces.CarPieces = append(
metadata.CarPieces.CarPieces,
carlet.CarFile{
Name: currentSubsetInfo.fileName,
ContentSize: currentFileSize - uint64(len(nulRootCarHeader)),
HeaderSize: uint64(len(nulRootCarHeader)),
CommP: commCid,
PaddedSize: ps,
})

err = closeFile(bufferedWriter, currentFile)
if err != nil {
Expand Down Expand Up @@ -322,8 +338,23 @@ func newCmd_SplitCar() *cli.Command {
return fmt.Errorf("failed to calculate commitment to cid: %w", err)
}

carFiles = append(carFiles, carFile{name: fmt.Sprintf("epoch-%d-%d.car", epoch, currentFileNum), commP: commCid, payloadCid: sl.(cidlink.Link).Cid, paddedSize: ps, fileSize: currentFileSize})
metadata.CarPieces.CarPieces = append(metadata.CarPieces.CarPieces, carlet.CarFile{Name: currentSubsetInfo.fileName, ContentSize: currentFileSize, HeaderSize: uint64(len(nulRootCarHeader)), CommP: commCid})
carFiles = append(
carFiles,
carFile{
name: fmt.Sprintf("epoch-%d-%d.car", epoch, currentFileNum),
commP: commCid,
payloadCid: sl.(cidlink.Link).Cid,
paddedSize: ps,
fileSize: currentFileSize,
})
metadata.CarPieces.CarPieces = append(
metadata.CarPieces.CarPieces,
carlet.CarFile{
Name: currentSubsetInfo.fileName,
ContentSize: currentFileSize - uint64(len(nulRootCarHeader)),
HeaderSize: uint64(len(nulRootCarHeader)),
CommP: commCid,
})

f, err := os.Create(meta)
defer f.Close()
Expand Down Expand Up @@ -428,7 +459,7 @@ func writeNode(node datamodel.Node, w io.Writer) (cid.Cid, error) {
return cd, nil
}

func writeMetadata(metadata []Metadata, epoch int) error {
func writeMetadata(metadata *splitcarfetcher.Metadata, epoch int) error {
metadataFileName := fmt.Sprintf("epoch-%d-metadata.yaml", epoch)

// Open file in append mode
Expand Down

0 comments on commit 3bf2873

Please sign in to comment.