this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

return written blocks in closing deltasession

+22 -1
+22 -1
carstore/bs.go
··· 607 607 case *FileCarStore: 608 608 return ocs.writeNewShard(ctx, root, rev, ds.user, ds.seq, ds.blks, ds.rmcids) 609 609 case *NonArchivalCarstore: 610 - return nil, ocs.updateLastCommit(ctx, ds.user, rev, root) 610 + slice, err := blocksToCar(ctx, root, rev, ds.blks) 611 + if err != nil { 612 + return nil, err 613 + } 614 + return slice, ocs.updateLastCommit(ctx, ds.user, rev, root) 611 615 default: 612 616 return nil, fmt.Errorf("unsupported carstore type") 613 617 } ··· 629 633 } 630 634 631 635 return hnw, nil 636 + } 637 + 638 + func blocksToCar(ctx context.Context, root cid.Cid, rev string, blks map[cid.Cid]blockformat.Block) ([]byte, error) { 639 + buf := new(bytes.Buffer) 640 + _, err := WriteCarHeader(buf, root) 641 + if err != nil { 642 + return nil, fmt.Errorf("failed to write car header: %w", err) 643 + } 644 + 645 + for k, blk := range blks { 646 + _, err := LdWrite(buf, k.Bytes(), blk.RawData()) 647 + if err != nil { 648 + return nil, fmt.Errorf("failed to write block: %w", err) 649 + } 650 + } 651 + 652 + return buf.Bytes(), nil 632 653 } 633 654 634 655 func (cs *FileCarStore) writeNewShard(ctx context.Context, root cid.Cid, rev string, user models.Uid, seq int, blks map[cid.Cid]blockformat.Block, rmcids map[cid.Cid]bool) ([]byte, error) {