Add putObj and putMany to apiBlockstore
This commit is contained in:
parent
81cacd76a7
commit
5c0f2c8ae6
@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
blocks "github.com/ipfs/go-block-format"
|
||||
"github.com/ipfs/go-cid"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
|
||||
@ -38,6 +39,8 @@ import (
|
||||
type ChainIO interface {
|
||||
ChainReadObj(context.Context, cid.Cid) ([]byte, error)
|
||||
ChainHasObj(context.Context, cid.Cid) (bool, error)
|
||||
ChainPutObj(context.Context, blocks.Block) error
|
||||
ChainPutMany(context.Context, []blocks.Block) error
|
||||
}
|
||||
|
||||
const LookbackNoLimit = abi.ChainEpoch(-1)
|
||||
@ -123,6 +126,12 @@ type FullNode interface {
|
||||
// ChainHasObj checks if a given CID exists in the chain blockstore.
|
||||
ChainHasObj(context.Context, cid.Cid) (bool, error) //perm:read
|
||||
|
||||
// ChainPutObj puts a given object into the block store
|
||||
ChainPutObj(context.Context, blocks.Block) error //perm:admin
|
||||
|
||||
// ChainPutMany puts a given array of objects into the block store
|
||||
ChainPutMany(context.Context, []blocks.Block) error //perm:admin
|
||||
|
||||
// ChainStatObj returns statistics about the graph referenced by 'obj'.
|
||||
// If 'base' is also specified, then the returned stat will be a diff
|
||||
// between the two objects.
|
||||
|
@ -3,6 +3,7 @@ package api
|
||||
import (
|
||||
"context"
|
||||
|
||||
blocks "github.com/ipfs/go-block-format"
|
||||
"github.com/ipfs/go-cid"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
@ -30,6 +31,8 @@ import (
|
||||
|
||||
type Gateway interface {
|
||||
ChainHasObj(context.Context, cid.Cid) (bool, error)
|
||||
ChainPutObj(context.Context, blocks.Block) error
|
||||
ChainPutMany(context.Context, []blocks.Block) error
|
||||
ChainHead(ctx context.Context) (*types.TipSet, error)
|
||||
ChainGetParentMessages(context.Context, cid.Cid) ([]Message, error)
|
||||
ChainGetParentReceipts(context.Context, cid.Cid) ([]*types.MessageReceipt, error)
|
||||
|
@ -28,6 +28,7 @@ import (
|
||||
filestore "github.com/filecoin-project/go-fil-markets/filestore"
|
||||
"github.com/filecoin-project/go-fil-markets/retrievalmarket"
|
||||
"github.com/filecoin-project/go-jsonrpc/auth"
|
||||
blocks "github.com/ipfs/go-block-format"
|
||||
textselector "github.com/ipld/go-ipld-selector-text-lite"
|
||||
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
@ -95,6 +96,9 @@ func init() {
|
||||
apiSelExample := api.Selector("Links/21/Hash/Links/42/Hash")
|
||||
clientEvent := retrievalmarket.ClientEventDealAccepted
|
||||
|
||||
block := blocks.Block(&blocks.BasicBlock{})
|
||||
ExampleValues[reflect.TypeOf(&block).Elem()] = block
|
||||
|
||||
addExample(bitfield.NewFromSet([]uint64{5}))
|
||||
addExample(abi.RegisteredSealProof_StackedDrg32GiBV1_1)
|
||||
addExample(abi.RegisteredPoStProof_StackedDrgWindow32GiBV1)
|
||||
|
@ -31,6 +31,7 @@ import (
|
||||
imports "github.com/filecoin-project/lotus/node/repo/imports"
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
uuid "github.com/google/uuid"
|
||||
blocks "github.com/ipfs/go-block-format"
|
||||
cid "github.com/ipfs/go-cid"
|
||||
metrics "github.com/libp2p/go-libp2p-core/metrics"
|
||||
network0 "github.com/libp2p/go-libp2p-core/network"
|
||||
@ -374,6 +375,34 @@ func (mr *MockFullNodeMockRecorder) ChainNotify(arg0 interface{}) *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ChainNotify", reflect.TypeOf((*MockFullNode)(nil).ChainNotify), arg0)
|
||||
}
|
||||
|
||||
// ChainPutMany mocks base method.
|
||||
func (m *MockFullNode) ChainPutMany(arg0 context.Context, arg1 []blocks.Block) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ChainPutMany", arg0, arg1)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// ChainPutMany indicates an expected call of ChainPutMany.
|
||||
func (mr *MockFullNodeMockRecorder) ChainPutMany(arg0, arg1 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ChainPutMany", reflect.TypeOf((*MockFullNode)(nil).ChainPutMany), arg0, arg1)
|
||||
}
|
||||
|
||||
// ChainPutObj mocks base method.
|
||||
func (m *MockFullNode) ChainPutObj(arg0 context.Context, arg1 blocks.Block) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ChainPutObj", arg0, arg1)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// ChainPutObj indicates an expected call of ChainPutObj.
|
||||
func (mr *MockFullNodeMockRecorder) ChainPutObj(arg0, arg1 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ChainPutObj", reflect.TypeOf((*MockFullNode)(nil).ChainPutObj), arg0, arg1)
|
||||
}
|
||||
|
||||
// ChainReadObj mocks base method.
|
||||
func (m *MockFullNode) ChainReadObj(arg0 context.Context, arg1 cid.Cid) ([]byte, error) {
|
||||
m.ctrl.T.Helper()
|
||||
|
@ -34,6 +34,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/node/repo/imports"
|
||||
"github.com/filecoin-project/specs-storage/storage"
|
||||
"github.com/google/uuid"
|
||||
blocks "github.com/ipfs/go-block-format"
|
||||
"github.com/ipfs/go-cid"
|
||||
metrics "github.com/libp2p/go-libp2p-core/metrics"
|
||||
"github.com/libp2p/go-libp2p-core/network"
|
||||
@ -48,6 +49,10 @@ type ChainIOStruct struct {
|
||||
Internal struct {
|
||||
ChainHasObj func(p0 context.Context, p1 cid.Cid) (bool, error) ``
|
||||
|
||||
ChainPutMany func(p0 context.Context, p1 []blocks.Block) error ``
|
||||
|
||||
ChainPutObj func(p0 context.Context, p1 blocks.Block) error ``
|
||||
|
||||
ChainReadObj func(p0 context.Context, p1 cid.Cid) ([]byte, error) ``
|
||||
}
|
||||
}
|
||||
@ -141,6 +146,10 @@ type FullNodeStruct struct {
|
||||
|
||||
ChainNotify func(p0 context.Context) (<-chan []*HeadChange, error) `perm:"read"`
|
||||
|
||||
ChainPutMany func(p0 context.Context, p1 []blocks.Block) error `perm:"admin"`
|
||||
|
||||
ChainPutObj func(p0 context.Context, p1 blocks.Block) error `perm:"admin"`
|
||||
|
||||
ChainReadObj func(p0 context.Context, p1 cid.Cid) ([]byte, error) `perm:"read"`
|
||||
|
||||
ChainSetHead func(p0 context.Context, p1 types.TipSetKey) error `perm:"admin"`
|
||||
@ -511,6 +520,10 @@ type GatewayStruct struct {
|
||||
|
||||
ChainNotify func(p0 context.Context) (<-chan []*HeadChange, error) ``
|
||||
|
||||
ChainPutMany func(p0 context.Context, p1 []blocks.Block) error ``
|
||||
|
||||
ChainPutObj func(p0 context.Context, p1 blocks.Block) error ``
|
||||
|
||||
ChainReadObj func(p0 context.Context, p1 cid.Cid) ([]byte, error) ``
|
||||
|
||||
GasEstimateMessageGas func(p0 context.Context, p1 *types.Message, p2 *MessageSendSpec, p3 types.TipSetKey) (*types.Message, error) ``
|
||||
@ -977,6 +990,28 @@ func (s *ChainIOStub) ChainHasObj(p0 context.Context, p1 cid.Cid) (bool, error)
|
||||
return false, ErrNotSupported
|
||||
}
|
||||
|
||||
func (s *ChainIOStruct) ChainPutMany(p0 context.Context, p1 []blocks.Block) error {
|
||||
if s.Internal.ChainPutMany == nil {
|
||||
return ErrNotSupported
|
||||
}
|
||||
return s.Internal.ChainPutMany(p0, p1)
|
||||
}
|
||||
|
||||
func (s *ChainIOStub) ChainPutMany(p0 context.Context, p1 []blocks.Block) error {
|
||||
return ErrNotSupported
|
||||
}
|
||||
|
||||
func (s *ChainIOStruct) ChainPutObj(p0 context.Context, p1 blocks.Block) error {
|
||||
if s.Internal.ChainPutObj == nil {
|
||||
return ErrNotSupported
|
||||
}
|
||||
return s.Internal.ChainPutObj(p0, p1)
|
||||
}
|
||||
|
||||
func (s *ChainIOStub) ChainPutObj(p0 context.Context, p1 blocks.Block) error {
|
||||
return ErrNotSupported
|
||||
}
|
||||
|
||||
func (s *ChainIOStruct) ChainReadObj(p0 context.Context, p1 cid.Cid) ([]byte, error) {
|
||||
if s.Internal.ChainReadObj == nil {
|
||||
return *new([]byte), ErrNotSupported
|
||||
@ -1307,6 +1342,28 @@ func (s *FullNodeStub) ChainNotify(p0 context.Context) (<-chan []*HeadChange, er
|
||||
return nil, ErrNotSupported
|
||||
}
|
||||
|
||||
func (s *FullNodeStruct) ChainPutMany(p0 context.Context, p1 []blocks.Block) error {
|
||||
if s.Internal.ChainPutMany == nil {
|
||||
return ErrNotSupported
|
||||
}
|
||||
return s.Internal.ChainPutMany(p0, p1)
|
||||
}
|
||||
|
||||
func (s *FullNodeStub) ChainPutMany(p0 context.Context, p1 []blocks.Block) error {
|
||||
return ErrNotSupported
|
||||
}
|
||||
|
||||
func (s *FullNodeStruct) ChainPutObj(p0 context.Context, p1 blocks.Block) error {
|
||||
if s.Internal.ChainPutObj == nil {
|
||||
return ErrNotSupported
|
||||
}
|
||||
return s.Internal.ChainPutObj(p0, p1)
|
||||
}
|
||||
|
||||
func (s *FullNodeStub) ChainPutObj(p0 context.Context, p1 blocks.Block) error {
|
||||
return ErrNotSupported
|
||||
}
|
||||
|
||||
func (s *FullNodeStruct) ChainReadObj(p0 context.Context, p1 cid.Cid) ([]byte, error) {
|
||||
if s.Internal.ChainReadObj == nil {
|
||||
return *new([]byte), ErrNotSupported
|
||||
@ -3287,6 +3344,28 @@ func (s *GatewayStub) ChainNotify(p0 context.Context) (<-chan []*HeadChange, err
|
||||
return nil, ErrNotSupported
|
||||
}
|
||||
|
||||
func (s *GatewayStruct) ChainPutMany(p0 context.Context, p1 []blocks.Block) error {
|
||||
if s.Internal.ChainPutMany == nil {
|
||||
return ErrNotSupported
|
||||
}
|
||||
return s.Internal.ChainPutMany(p0, p1)
|
||||
}
|
||||
|
||||
func (s *GatewayStub) ChainPutMany(p0 context.Context, p1 []blocks.Block) error {
|
||||
return ErrNotSupported
|
||||
}
|
||||
|
||||
func (s *GatewayStruct) ChainPutObj(p0 context.Context, p1 blocks.Block) error {
|
||||
if s.Internal.ChainPutObj == nil {
|
||||
return ErrNotSupported
|
||||
}
|
||||
return s.Internal.ChainPutObj(p0, p1)
|
||||
}
|
||||
|
||||
func (s *GatewayStub) ChainPutObj(p0 context.Context, p1 blocks.Block) error {
|
||||
return ErrNotSupported
|
||||
}
|
||||
|
||||
func (s *GatewayStruct) ChainReadObj(p0 context.Context, p1 cid.Cid) ([]byte, error) {
|
||||
if s.Internal.ChainReadObj == nil {
|
||||
return *new([]byte), ErrNotSupported
|
||||
|
@ -11,6 +11,7 @@ import (
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/go-state-types/crypto"
|
||||
"github.com/filecoin-project/go-state-types/dline"
|
||||
blocks "github.com/ipfs/go-block-format"
|
||||
"github.com/ipfs/go-cid"
|
||||
textselector "github.com/ipld/go-ipld-selector-text-lite"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
@ -110,6 +111,12 @@ type FullNode interface {
|
||||
// ChainDeleteObj deletes node referenced by the given CID
|
||||
ChainDeleteObj(context.Context, cid.Cid) error //perm:admin
|
||||
|
||||
// ChainPutObj puts and object into the blockstore
|
||||
ChainPutObj(context.Context, blocks.Block) error
|
||||
|
||||
// ChainPutMany puts an array of objects into the blockstore
|
||||
ChainPutMany(context.Context, []blocks.Block) error
|
||||
|
||||
// ChainHasObj checks if a given CID exists in the chain blockstore.
|
||||
ChainHasObj(context.Context, cid.Cid) (bool, error) //perm:read
|
||||
|
||||
|
@ -3,6 +3,7 @@ package v0api
|
||||
import (
|
||||
"context"
|
||||
|
||||
blocks "github.com/ipfs/go-block-format"
|
||||
"github.com/ipfs/go-cid"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
@ -34,6 +35,8 @@ import (
|
||||
|
||||
type Gateway interface {
|
||||
ChainHasObj(context.Context, cid.Cid) (bool, error)
|
||||
ChainPutObj(context.Context, blocks.Block) error
|
||||
ChainPutMany(context.Context, []blocks.Block) error
|
||||
ChainHead(ctx context.Context) (*types.TipSet, error)
|
||||
ChainGetBlockMessages(context.Context, cid.Cid) (*api.BlockMessages, error)
|
||||
ChainGetMessage(ctx context.Context, mc cid.Cid) (*types.Message, error)
|
||||
|
@ -23,6 +23,7 @@ import (
|
||||
marketevents "github.com/filecoin-project/lotus/markets/loggers"
|
||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||
"github.com/filecoin-project/lotus/node/repo/imports"
|
||||
blocks "github.com/ipfs/go-block-format"
|
||||
"github.com/ipfs/go-cid"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"golang.org/x/xerrors"
|
||||
@ -74,6 +75,10 @@ type FullNodeStruct struct {
|
||||
|
||||
ChainNotify func(p0 context.Context) (<-chan []*api.HeadChange, error) `perm:"read"`
|
||||
|
||||
ChainPutMany func(p0 context.Context, p1 []blocks.Block) error ``
|
||||
|
||||
ChainPutObj func(p0 context.Context, p1 blocks.Block) error ``
|
||||
|
||||
ChainReadObj func(p0 context.Context, p1 cid.Cid) ([]byte, error) `perm:"read"`
|
||||
|
||||
ChainSetHead func(p0 context.Context, p1 types.TipSetKey) error `perm:"admin"`
|
||||
@ -420,6 +425,10 @@ type GatewayStruct struct {
|
||||
|
||||
ChainNotify func(p0 context.Context) (<-chan []*api.HeadChange, error) ``
|
||||
|
||||
ChainPutMany func(p0 context.Context, p1 []blocks.Block) error ``
|
||||
|
||||
ChainPutObj func(p0 context.Context, p1 blocks.Block) error ``
|
||||
|
||||
ChainReadObj func(p0 context.Context, p1 cid.Cid) ([]byte, error) ``
|
||||
|
||||
GasEstimateMessageGas func(p0 context.Context, p1 *types.Message, p2 *api.MessageSendSpec, p3 types.TipSetKey) (*types.Message, error) ``
|
||||
@ -682,6 +691,28 @@ func (s *FullNodeStub) ChainNotify(p0 context.Context) (<-chan []*api.HeadChange
|
||||
return nil, ErrNotSupported
|
||||
}
|
||||
|
||||
func (s *FullNodeStruct) ChainPutMany(p0 context.Context, p1 []blocks.Block) error {
|
||||
if s.Internal.ChainPutMany == nil {
|
||||
return ErrNotSupported
|
||||
}
|
||||
return s.Internal.ChainPutMany(p0, p1)
|
||||
}
|
||||
|
||||
func (s *FullNodeStub) ChainPutMany(p0 context.Context, p1 []blocks.Block) error {
|
||||
return ErrNotSupported
|
||||
}
|
||||
|
||||
func (s *FullNodeStruct) ChainPutObj(p0 context.Context, p1 blocks.Block) error {
|
||||
if s.Internal.ChainPutObj == nil {
|
||||
return ErrNotSupported
|
||||
}
|
||||
return s.Internal.ChainPutObj(p0, p1)
|
||||
}
|
||||
|
||||
func (s *FullNodeStub) ChainPutObj(p0 context.Context, p1 blocks.Block) error {
|
||||
return ErrNotSupported
|
||||
}
|
||||
|
||||
func (s *FullNodeStruct) ChainReadObj(p0 context.Context, p1 cid.Cid) ([]byte, error) {
|
||||
if s.Internal.ChainReadObj == nil {
|
||||
return *new([]byte), ErrNotSupported
|
||||
@ -2530,6 +2561,28 @@ func (s *GatewayStub) ChainNotify(p0 context.Context) (<-chan []*api.HeadChange,
|
||||
return nil, ErrNotSupported
|
||||
}
|
||||
|
||||
func (s *GatewayStruct) ChainPutMany(p0 context.Context, p1 []blocks.Block) error {
|
||||
if s.Internal.ChainPutMany == nil {
|
||||
return ErrNotSupported
|
||||
}
|
||||
return s.Internal.ChainPutMany(p0, p1)
|
||||
}
|
||||
|
||||
func (s *GatewayStub) ChainPutMany(p0 context.Context, p1 []blocks.Block) error {
|
||||
return ErrNotSupported
|
||||
}
|
||||
|
||||
func (s *GatewayStruct) ChainPutObj(p0 context.Context, p1 blocks.Block) error {
|
||||
if s.Internal.ChainPutObj == nil {
|
||||
return ErrNotSupported
|
||||
}
|
||||
return s.Internal.ChainPutObj(p0, p1)
|
||||
}
|
||||
|
||||
func (s *GatewayStub) ChainPutObj(p0 context.Context, p1 blocks.Block) error {
|
||||
return ErrNotSupported
|
||||
}
|
||||
|
||||
func (s *GatewayStruct) ChainReadObj(p0 context.Context, p1 cid.Cid) ([]byte, error) {
|
||||
if s.Internal.ChainReadObj == nil {
|
||||
return *new([]byte), ErrNotSupported
|
||||
|
@ -33,6 +33,7 @@ import (
|
||||
imports "github.com/filecoin-project/lotus/node/repo/imports"
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
uuid "github.com/google/uuid"
|
||||
blocks "github.com/ipfs/go-block-format"
|
||||
cid "github.com/ipfs/go-cid"
|
||||
metrics "github.com/libp2p/go-libp2p-core/metrics"
|
||||
network0 "github.com/libp2p/go-libp2p-core/network"
|
||||
@ -377,6 +378,34 @@ func (mr *MockFullNodeMockRecorder) ChainNotify(arg0 interface{}) *gomock.Call {
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ChainNotify", reflect.TypeOf((*MockFullNode)(nil).ChainNotify), arg0)
|
||||
}
|
||||
|
||||
// ChainPutMany mocks base method.
|
||||
func (m *MockFullNode) ChainPutMany(arg0 context.Context, arg1 []blocks.Block) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ChainPutMany", arg0, arg1)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// ChainPutMany indicates an expected call of ChainPutMany.
|
||||
func (mr *MockFullNodeMockRecorder) ChainPutMany(arg0, arg1 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ChainPutMany", reflect.TypeOf((*MockFullNode)(nil).ChainPutMany), arg0, arg1)
|
||||
}
|
||||
|
||||
// ChainPutObj mocks base method.
|
||||
func (m *MockFullNode) ChainPutObj(arg0 context.Context, arg1 blocks.Block) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "ChainPutObj", arg0, arg1)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// ChainPutObj indicates an expected call of ChainPutObj.
|
||||
func (mr *MockFullNodeMockRecorder) ChainPutObj(arg0, arg1 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ChainPutObj", reflect.TypeOf((*MockFullNode)(nil).ChainPutObj), arg0, arg1)
|
||||
}
|
||||
|
||||
// ChainReadObj mocks base method.
|
||||
func (m *MockFullNode) ChainReadObj(arg0 context.Context, arg1 cid.Cid) ([]byte, error) {
|
||||
m.ctrl.T.Helper()
|
||||
|
@ -11,6 +11,8 @@ import (
|
||||
type ChainIO interface {
|
||||
ChainReadObj(context.Context, cid.Cid) ([]byte, error)
|
||||
ChainHasObj(context.Context, cid.Cid) (bool, error)
|
||||
ChainPutObj(context.Context, blocks.Block) error
|
||||
ChainPutMany(context.Context, []blocks.Block) error
|
||||
}
|
||||
|
||||
type apiBlockstore struct {
|
||||
@ -49,12 +51,12 @@ func (a *apiBlockstore) GetSize(ctx context.Context, c cid.Cid) (int, error) {
|
||||
return len(bb), nil
|
||||
}
|
||||
|
||||
func (a *apiBlockstore) Put(context.Context, blocks.Block) error {
|
||||
return xerrors.New("not supported")
|
||||
func (a *apiBlockstore) Put(ctx context.Context, block blocks.Block) error {
|
||||
return a.api.ChainPutObj(ctx, block)
|
||||
}
|
||||
|
||||
func (a *apiBlockstore) PutMany(context.Context, []blocks.Block) error {
|
||||
return xerrors.New("not supported")
|
||||
func (a *apiBlockstore) PutMany(ctx context.Context, blocks []blocks.Block) error {
|
||||
return a.api.ChainPutMany(ctx, blocks)
|
||||
}
|
||||
|
||||
func (a *apiBlockstore) AllKeysChan(ctx context.Context) (<-chan cid.Cid, error) {
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
blocks "github.com/ipfs/go-block-format"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/lotus/blockstore"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
@ -39,6 +41,14 @@ func (m *MockAPI) ChainReadObj(ctx context.Context, c cid.Cid) ([]byte, error) {
|
||||
return blk.RawData(), nil
|
||||
}
|
||||
|
||||
func (m *MockAPI) ChainPutObj(ctx context.Context, block blocks.Block) error {
|
||||
return m.bs.Put(ctx, block)
|
||||
}
|
||||
|
||||
func (m *MockAPI) ChainPutMany(ctx context.Context, blocks []blocks.Block) error {
|
||||
return m.bs.PutMany(ctx, blocks)
|
||||
}
|
||||
|
||||
func (m *MockAPI) StateGetActor(ctx context.Context, actor address.Address, tsk types.TipSetKey) (*types.Actor, error) {
|
||||
m.lk.Lock()
|
||||
defer m.lk.Unlock()
|
||||
|
@ -29,6 +29,8 @@
|
||||
* [ChainHasObj](#ChainHasObj)
|
||||
* [ChainHead](#ChainHead)
|
||||
* [ChainNotify](#ChainNotify)
|
||||
* [ChainPutMany](#ChainPutMany)
|
||||
* [ChainPutObj](#ChainPutObj)
|
||||
* [ChainReadObj](#ChainReadObj)
|
||||
* [ChainSetHead](#ChainSetHead)
|
||||
* [ChainStatObj](#ChainStatObj)
|
||||
@ -971,6 +973,38 @@ Response:
|
||||
]
|
||||
```
|
||||
|
||||
### ChainPutMany
|
||||
ChainPutMany puts an array of objects into the blockstore
|
||||
|
||||
|
||||
Perms:
|
||||
|
||||
Inputs:
|
||||
```json
|
||||
[
|
||||
[
|
||||
{}
|
||||
]
|
||||
]
|
||||
```
|
||||
|
||||
Response: `{}`
|
||||
|
||||
### ChainPutObj
|
||||
ChainPutObj puts and object into the blockstore
|
||||
|
||||
|
||||
Perms:
|
||||
|
||||
Inputs:
|
||||
```json
|
||||
[
|
||||
{}
|
||||
]
|
||||
```
|
||||
|
||||
Response: `{}`
|
||||
|
||||
### ChainReadObj
|
||||
ChainReadObj reads ipld nodes referenced by the specified CID from chain
|
||||
blockstore and returns raw bytes.
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
blocks "github.com/ipfs/go-block-format"
|
||||
"github.com/ipfs/go-cid"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
@ -46,6 +47,8 @@ type TargetAPI interface {
|
||||
ChainNotify(context.Context) (<-chan []*api.HeadChange, error)
|
||||
ChainGetPath(ctx context.Context, from, to types.TipSetKey) ([]*api.HeadChange, error)
|
||||
ChainReadObj(context.Context, cid.Cid) ([]byte, error)
|
||||
ChainPutObj(context.Context, blocks.Block) error
|
||||
ChainPutMany(context.Context, []blocks.Block) error
|
||||
ChainGetGenesis(context.Context) (*types.TipSet, error)
|
||||
GasEstimateMessageGas(ctx context.Context, msg *types.Message, spec *api.MessageSendSpec, tsk types.TipSetKey) (*types.Message, error)
|
||||
MpoolPushUntrusted(ctx context.Context, sm *types.SignedMessage) (cid.Cid, error)
|
||||
@ -251,6 +254,14 @@ func (gw *Node) ChainReadObj(ctx context.Context, c cid.Cid) ([]byte, error) {
|
||||
return gw.target.ChainReadObj(ctx, c)
|
||||
}
|
||||
|
||||
func (gw *Node) ChainPutObj(ctx context.Context, block blocks.Block) error {
|
||||
return gw.target.ChainPutObj(ctx, block)
|
||||
}
|
||||
|
||||
func (gw *Node) ChainPutMany(ctx context.Context, blocks []blocks.Block) error {
|
||||
return gw.target.ChainPutMany(ctx, blocks)
|
||||
}
|
||||
|
||||
func (gw *Node) GasEstimateMessageGas(ctx context.Context, msg *types.Message, spec *api.MessageSendSpec, tsk types.TipSetKey) (*types.Message, error) {
|
||||
if err := gw.checkTipsetKey(ctx, tsk); err != nil {
|
||||
return nil, err
|
||||
|
@ -3,6 +3,7 @@ package storageadapter
|
||||
import (
|
||||
"context"
|
||||
|
||||
blocks "github.com/ipfs/go-block-format"
|
||||
"github.com/ipfs/go-cid"
|
||||
cbor "github.com/ipfs/go-ipld-cbor"
|
||||
"golang.org/x/xerrors"
|
||||
@ -20,6 +21,8 @@ type apiWrapper struct {
|
||||
StateGetActor(ctx context.Context, actor address.Address, tsk types.TipSetKey) (*types.Actor, error)
|
||||
ChainReadObj(context.Context, cid.Cid) ([]byte, error)
|
||||
ChainHasObj(context.Context, cid.Cid) (bool, error)
|
||||
ChainPutObj(context.Context, blocks.Block) error
|
||||
ChainPutMany(context.Context, []blocks.Block) error
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ import (
|
||||
"go.uber.org/fx"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
blocks "github.com/ipfs/go-block-format"
|
||||
"github.com/ipfs/go-blockservice"
|
||||
"github.com/ipfs/go-cid"
|
||||
offline "github.com/ipfs/go-ipfs-exchange-offline"
|
||||
@ -261,6 +262,14 @@ func (m *ChainModule) ChainReadObj(ctx context.Context, obj cid.Cid) ([]byte, er
|
||||
return blk.RawData(), nil
|
||||
}
|
||||
|
||||
func (a *ChainAPI) ChainPutObj(ctx context.Context, obj blocks.Block) error {
|
||||
return a.ExposedBlockstore.Put(ctx, obj)
|
||||
}
|
||||
|
||||
func (a *ChainAPI) ChainPutMany(ctx context.Context, objs []blocks.Block) error {
|
||||
return a.ExposedBlockstore.PutMany(ctx, objs)
|
||||
}
|
||||
|
||||
func (a *ChainAPI) ChainDeleteObj(ctx context.Context, obj cid.Cid) error {
|
||||
return a.ExposedBlockstore.DeleteBlock(ctx, obj)
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/filecoin-project/go-bitfield"
|
||||
blocks "github.com/ipfs/go-block-format"
|
||||
"github.com/ipfs/go-cid"
|
||||
"github.com/ipfs/go-datastore"
|
||||
logging "github.com/ipfs/go-log/v2"
|
||||
@ -122,6 +123,8 @@ type fullNodeFilteredAPI interface {
|
||||
ChainGetPath(ctx context.Context, from, to types.TipSetKey) ([]*api.HeadChange, error)
|
||||
ChainReadObj(context.Context, cid.Cid) ([]byte, error)
|
||||
ChainHasObj(context.Context, cid.Cid) (bool, error)
|
||||
ChainPutObj(context.Context, blocks.Block) error
|
||||
ChainPutMany(context.Context, []blocks.Block) error
|
||||
ChainGetTipSet(ctx context.Context, key types.TipSetKey) (*types.TipSet, error)
|
||||
|
||||
WalletSign(context.Context, address.Address, []byte) (*crypto.Signature, error)
|
||||
|
Loading…
Reference in New Issue
Block a user