Add a command to read an object by its cid

This commit is contained in:
whyrusleeping
2019-10-01 10:28:07 -06:00
parent 62e596d0a3
commit 404e14d3eb
4 changed files with 41 additions and 0 deletions
+9
View File
@@ -122,3 +122,12 @@ func (a *ChainAPI) ChainGetBlockReceipts(ctx context.Context, bcid cid.Cid) ([]*
func (a *ChainAPI) ChainGetTipSetByHeight(ctx context.Context, h uint64, ts *types.TipSet) (*types.TipSet, error) {
return a.Chain.GetTipsetByHeight(ctx, h, ts)
}
func (a *ChainAPI) ChainReadObj(ctx context.Context, obj cid.Cid) ([]byte, error) {
blk, err := a.Chain.Blockstore().Get(obj)
if err != nil {
return nil, xerrors.Errorf("blockstore get: %w", err)
}
return blk.RawData(), nil
}