Skip to content

Commit

Permalink
Merge pull request #5743 from filecoin-project/fix/store-receipt
Browse files Browse the repository at this point in the history
fix: fix store receipts
  • Loading branch information
diwufeiwen authored Feb 22, 2023
2 parents f793676 + 089881e commit a0d46f4
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions pkg/chain/message_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,25 +329,14 @@ func (ms *MessageStore) LoadReceipts(ctx context.Context, c cid.Cid) ([]types.Me
// StoreReceipts puts the input signed messages to a collection and then writes
// this collection to ipld storage. The cid of the collection is returned.
func (ms *MessageStore) StoreReceipts(ctx context.Context, receipts []types.MessageReceipt) (cid.Cid, error) {
tmp := blockstoreutil.NewTemporary()
rectarr := adt.MakeEmptyArray(adt.WrapStore(ctx, cbor.NewCborStore(tmp)))
rectarr := adt.MakeEmptyArray(adt.WrapStore(ctx, cbor.NewCborStore(ms.bs)))

for i, receipt := range receipts {
if err := rectarr.Set(uint64(i), &receipt); err != nil {
return cid.Undef, errors.Wrap(err, "failed to build receipts amt")
}
}

root, err := rectarr.Root()
if err != nil {
return cid.Undef, err
}

err = blockstoreutil.CopyParticial(ctx, tmp, ms.bs, root)
if err != nil {
return cid.Undef, err
}

return rectarr.Root()
}

Expand Down

0 comments on commit a0d46f4

Please sign in to comment.