Skip to content

Commit

Permalink
payload cid (rpcpool#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
anjor authored Jul 29, 2024
1 parent 70c3cc4 commit c9b1840
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
8 changes: 5 additions & 3 deletions cmd-car-split.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ type subsetInfo struct {
type carFile struct {
name string
commP cid.Cid
payloadCid cid.Cid
paddedSize uint64
fileSize int64
}
Expand Down Expand Up @@ -170,7 +171,7 @@ 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, paddedSize: ps, fileSize: currentFileSize})
carFiles = append(carFiles, carFile{name: fmt.Sprintf("epoch-%d-%d.car", epoch, currentFileNum), commP: commCid, payloadCid: sl.(cidlink.Link).Cid, paddedSize: ps, fileSize: currentFileSize})

err = closeFile(bufferedWriter, currentFile)
if err != nil {
Expand Down Expand Up @@ -315,7 +316,7 @@ 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, paddedSize: ps, fileSize: currentFileSize})
carFiles = append(carFiles, carFile{name: fmt.Sprintf("epoch-%d-%d.car", epoch, currentFileNum), commP: commCid, payloadCid: sl.(cidlink.Link).Cid, paddedSize: ps, fileSize: currentFileSize})

f, err := os.Create(meta)
defer f.Close()
Expand All @@ -324,7 +325,7 @@ func newCmd_SplitCar() *cli.Command {
}

w := csv.NewWriter(f)
err = w.Write([]string{"car file", "piece cid", "padded piece size", "file size"})
err = w.Write([]string{"car file", "piece cid", "payload cid", "padded piece size", "file size"})
if err != nil {
return err
}
Expand All @@ -333,6 +334,7 @@ func newCmd_SplitCar() *cli.Command {
err = w.Write([]string{
c.name,
c.commP.String(),
c.payloadCid.String(),
strconv.FormatUint(c.paddedSize, 10),
strconv.FormatInt(c.fileSize, 10),
})
Expand Down
10 changes: 6 additions & 4 deletions dataprep-tools/filecoin/boost_create_deals.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,12 @@ def create_deals(metadata_obj):
file_name = os.path.basename(line[0])
# Only allow the new metadata
assert (
len(line) == 4
), f"metadata.csv should have 4 columns, instead found {len(line)}, {line}"
len(line) == 5
), f"metadata.csv should have 5 columns, instead found f{len(line)}, {line}"

commp_piece_cid = line[1]
padded_size = line[2]
payload_cid = line[3]

check_obj = client.check_exists(epoch + "/" + file_name)
if not check_obj[0]:
Expand Down Expand Up @@ -417,9 +419,9 @@ def create_deals(metadata_obj):
client.connect()

# Load the payload CI
payload_cid = client.read_object("%s/epoch-%s.cid" % (epoch, epoch)).strip()
epoch_cid = client.read_object("%s/epoch-%s.cid" % (epoch, epoch)).strip()

logging.info("creating deals for epoch %s with payload %s", epoch, payload_cid)
logging.info("creating deals for epoch %s with payload %s", epoch, epoch_cid)

# Load metadata csv produced by split-and-commp
ret = 0
Expand Down

0 comments on commit c9b1840

Please sign in to comment.