From 81cacd76a7b670d0524a3c509003c28fb4f5646a Mon Sep 17 00:00:00 2001 From: Geoff Stuart Date: Mon, 6 Jun 2022 23:14:16 -0400 Subject: [PATCH 1/8] Implement function to access state of system actor --- chain/actors/builtin/system/actor.go.template | 2 ++ chain/actors/builtin/system/state.go.template | 8 ++++++++ chain/actors/builtin/system/system.go | 2 ++ chain/actors/builtin/system/v0.go | 6 ++++++ chain/actors/builtin/system/v2.go | 6 ++++++ chain/actors/builtin/system/v3.go | 6 ++++++ chain/actors/builtin/system/v4.go | 6 ++++++ chain/actors/builtin/system/v5.go | 6 ++++++ chain/actors/builtin/system/v6.go | 6 ++++++ chain/actors/builtin/system/v7.go | 6 ++++++ chain/actors/builtin/system/v8.go | 6 ++++++ 11 files changed, 60 insertions(+) diff --git a/chain/actors/builtin/system/actor.go.template b/chain/actors/builtin/system/actor.go.template index 616a20a76d1..a3fb6127d8a 100644 --- a/chain/actors/builtin/system/actor.go.template +++ b/chain/actors/builtin/system/actor.go.template @@ -4,6 +4,7 @@ import ( "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/types" + "github.com/ipfs/go-cid" "golang.org/x/xerrors" @@ -60,4 +61,5 @@ func MakeState(store adt.Store, av actors.Version) (State, error) { type State interface { GetState() interface{} + GetBuiltinActors() cid.Cid } diff --git a/chain/actors/builtin/system/state.go.template b/chain/actors/builtin/system/state.go.template index ddf458305e9..de3f2dcdf54 100644 --- a/chain/actors/builtin/system/state.go.template +++ b/chain/actors/builtin/system/state.go.template @@ -36,4 +36,12 @@ type state{{.v}} struct { func (s *state{{.v}}) GetState() interface{} { return &s.State +} + +func (s *state{{.v}}) GetBuiltinActors() cid.Cid { +{{if (le .v 7)}} + return cid.Undef +{{else}} + return s.State.BuiltinActors +{{end}} } \ No newline at end of file diff --git a/chain/actors/builtin/system/system.go b/chain/actors/builtin/system/system.go index 71d7f7024c0..fd3997147b0 100644 --- a/chain/actors/builtin/system/system.go +++ b/chain/actors/builtin/system/system.go @@ -4,6 +4,7 @@ import ( "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/adt" "github.com/filecoin-project/lotus/chain/types" + "github.com/ipfs/go-cid" "golang.org/x/xerrors" @@ -103,4 +104,5 @@ func MakeState(store adt.Store, av actors.Version) (State, error) { type State interface { GetState() interface{} + GetBuiltinActors() cid.Cid } diff --git a/chain/actors/builtin/system/v0.go b/chain/actors/builtin/system/v0.go index 64c6f53d3cf..a5aa8e8fa1b 100644 --- a/chain/actors/builtin/system/v0.go +++ b/chain/actors/builtin/system/v0.go @@ -33,3 +33,9 @@ type state0 struct { func (s *state0) GetState() interface{} { return &s.State } + +func (s *state0) GetBuiltinActors() cid.Cid { + + return cid.Undef + +} diff --git a/chain/actors/builtin/system/v2.go b/chain/actors/builtin/system/v2.go index eb540891cc3..aea9eff7b91 100644 --- a/chain/actors/builtin/system/v2.go +++ b/chain/actors/builtin/system/v2.go @@ -33,3 +33,9 @@ type state2 struct { func (s *state2) GetState() interface{} { return &s.State } + +func (s *state2) GetBuiltinActors() cid.Cid { + + return cid.Undef + +} diff --git a/chain/actors/builtin/system/v3.go b/chain/actors/builtin/system/v3.go index 5b04e189ee6..fd5f0cd5051 100644 --- a/chain/actors/builtin/system/v3.go +++ b/chain/actors/builtin/system/v3.go @@ -33,3 +33,9 @@ type state3 struct { func (s *state3) GetState() interface{} { return &s.State } + +func (s *state3) GetBuiltinActors() cid.Cid { + + return cid.Undef + +} diff --git a/chain/actors/builtin/system/v4.go b/chain/actors/builtin/system/v4.go index b6c92497884..fbdec7e93bf 100644 --- a/chain/actors/builtin/system/v4.go +++ b/chain/actors/builtin/system/v4.go @@ -33,3 +33,9 @@ type state4 struct { func (s *state4) GetState() interface{} { return &s.State } + +func (s *state4) GetBuiltinActors() cid.Cid { + + return cid.Undef + +} diff --git a/chain/actors/builtin/system/v5.go b/chain/actors/builtin/system/v5.go index 77d2a8478be..3d3c27a12e4 100644 --- a/chain/actors/builtin/system/v5.go +++ b/chain/actors/builtin/system/v5.go @@ -33,3 +33,9 @@ type state5 struct { func (s *state5) GetState() interface{} { return &s.State } + +func (s *state5) GetBuiltinActors() cid.Cid { + + return cid.Undef + +} diff --git a/chain/actors/builtin/system/v6.go b/chain/actors/builtin/system/v6.go index 689620afba7..3143088456c 100644 --- a/chain/actors/builtin/system/v6.go +++ b/chain/actors/builtin/system/v6.go @@ -33,3 +33,9 @@ type state6 struct { func (s *state6) GetState() interface{} { return &s.State } + +func (s *state6) GetBuiltinActors() cid.Cid { + + return cid.Undef + +} diff --git a/chain/actors/builtin/system/v7.go b/chain/actors/builtin/system/v7.go index 813add5fb14..3987db8dd40 100644 --- a/chain/actors/builtin/system/v7.go +++ b/chain/actors/builtin/system/v7.go @@ -33,3 +33,9 @@ type state7 struct { func (s *state7) GetState() interface{} { return &s.State } + +func (s *state7) GetBuiltinActors() cid.Cid { + + return cid.Undef + +} diff --git a/chain/actors/builtin/system/v8.go b/chain/actors/builtin/system/v8.go index 2e0e2ba56da..30e9d6be801 100644 --- a/chain/actors/builtin/system/v8.go +++ b/chain/actors/builtin/system/v8.go @@ -33,3 +33,9 @@ type state8 struct { func (s *state8) GetState() interface{} { return &s.State } + +func (s *state8) GetBuiltinActors() cid.Cid { + + return s.State.BuiltinActors + +} From 5c0f2c8ae67b79f4752a9837a8d27a0b5e4b2847 Mon Sep 17 00:00:00 2001 From: Geoff Stuart Date: Wed, 8 Jun 2022 12:50:27 -0400 Subject: [PATCH 2/8] Add putObj and putMany to apiBlockstore --- api/api_full.go | 9 + api/api_gateway.go | 3 + api/docgen/docgen.go | 4 + api/mocks/mock_full.go | 29 + api/proxy_gen.go | 79 + api/v0api/full.go | 7 + api/v0api/gateway.go | 3 + api/v0api/proxy_gen.go | 53 + api/v0api/v0mocks/mock_full.go | 29 + blockstore/api.go | 10 +- build/openrpc/full.json.gz | Bin 27613 -> 27680 bytes build/openrpc/miner.json.gz | Bin 13708 -> 13709 bytes build/openrpc/worker.json.gz | Bin 4614 -> 4613 bytes chain/events/state/mock/api.go | 10 + documentation/en/api-v0-methods.md | 34 + documentation/en/api-v1-unstable-methods.md | 7697 ------------------- gateway/node.go | 11 + markets/storageadapter/api.go | 3 + node/impl/full/chain.go | 9 + storage/miner.go | 3 + 20 files changed, 292 insertions(+), 7701 deletions(-) diff --git a/api/api_full.go b/api/api_full.go index 7abe419aaf0..0c8943dfe07 100644 --- a/api/api_full.go +++ b/api/api_full.go @@ -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. diff --git a/api/api_gateway.go b/api/api_gateway.go index 0dc1985b401..cab7f43a11e 100644 --- a/api/api_gateway.go +++ b/api/api_gateway.go @@ -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) diff --git a/api/docgen/docgen.go b/api/docgen/docgen.go index e590a8e7cf4..e015cf038fe 100644 --- a/api/docgen/docgen.go +++ b/api/docgen/docgen.go @@ -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) diff --git a/api/mocks/mock_full.go b/api/mocks/mock_full.go index 689a67834f9..16deb5b0997 100644 --- a/api/mocks/mock_full.go +++ b/api/mocks/mock_full.go @@ -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() diff --git a/api/proxy_gen.go b/api/proxy_gen.go index a0b474d8dcb..bfa57690865 100644 --- a/api/proxy_gen.go +++ b/api/proxy_gen.go @@ -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 diff --git a/api/v0api/full.go b/api/v0api/full.go index 30a0dfb8e0a..f0a05d36f9c 100644 --- a/api/v0api/full.go +++ b/api/v0api/full.go @@ -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 diff --git a/api/v0api/gateway.go b/api/v0api/gateway.go index e13e92dd386..7423ae9ebde 100644 --- a/api/v0api/gateway.go +++ b/api/v0api/gateway.go @@ -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) diff --git a/api/v0api/proxy_gen.go b/api/v0api/proxy_gen.go index bae8ba7824d..45721c008c6 100644 --- a/api/v0api/proxy_gen.go +++ b/api/v0api/proxy_gen.go @@ -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 diff --git a/api/v0api/v0mocks/mock_full.go b/api/v0api/v0mocks/mock_full.go index e807862e625..a89e0c897db 100644 --- a/api/v0api/v0mocks/mock_full.go +++ b/api/v0api/v0mocks/mock_full.go @@ -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() diff --git a/blockstore/api.go b/blockstore/api.go index dc4c034525d..aa88ed799f8 100644 --- a/blockstore/api.go +++ b/blockstore/api.go @@ -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) { diff --git a/build/openrpc/full.json.gz b/build/openrpc/full.json.gz index e1d7e7270b71b3a7cdec53a3ba8778ad108bc7e0..d8f18a122993b46e3e95a1939cad1f2199e272ff 100644 GIT binary patch delta 26607 zcmV)rK$*YY*8!l|0gxMi-r^*#I`x#7EWYC;zP4v_&xv#IKqMq#OaUAMw5>_yyZ;Ld zNpKZNQHgBh)YOSZVrhUt_pcj`?r#GcA`*q(V1KZ+vAwZ37!EKQ)4~3?0mnQ*gZ;rN z