Skip to content
This repository has been archived by the owner on Dec 19, 2022. It is now read-only.

feat: use venus-shared #191

Merged
merged 1 commit into from
Feb 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ require (
github.com/filecoin-project/specs-actors/v6 v6.0.1
github.com/filecoin-project/specs-actors/v7 v7.0.0-rc1
github.com/filecoin-project/specs-storage v0.2.0
github.com/filecoin-project/venus v1.2.0-rc6.0.20220221094150-d4d38654e179
github.com/filecoin-project/venus-market v1.0.2-0.20220210103815-5ea3e7f6c5ac
github.com/filecoin-project/venus v1.2.0
github.com/filecoin-project/venus-market v1.0.2-0.20220222071139-31fba26405cc
github.com/gbrlsnchs/jwt/v3 v3.0.1
github.com/golang/mock v1.6.0
github.com/google/uuid v1.3.0
Expand All @@ -45,7 +45,6 @@ require (
github.com/hashicorp/go-multierror v1.1.1
github.com/icza/backscanner v0.0.0-20210726202459-ac2ffc679f94
github.com/ipfs-force-community/venus-common-utils v0.0.0-20211122032945-eb6cab79c62a
github.com/ipfs-force-community/venus-gateway v1.2.0-rc2
github.com/ipfs/go-block-format v0.0.3
github.com/ipfs/go-cid v0.1.0
github.com/ipfs/go-datastore v0.5.1
Expand Down Expand Up @@ -91,12 +90,10 @@ require (
lukechampine.com/blake3 v1.1.7 // indirect
)

replace github.com/filecoin-project/filecoin-ffi => ./extern/filecoin-ffi

replace github.com/ipfs/go-ipfs-cmds => github.com/ipfs-force-community/go-ipfs-cmds v0.6.1-0.20210521090123-4587df7fa0ab

replace github.com/filecoin-project/go-jsonrpc => github.com/ipfs-force-community/go-jsonrpc v0.1.4-0.20210721095535-a67dff16de21

replace github.com/filecoin-project/go-statemachine => github.com/hunjixin/go-statemachine v0.0.0-20220110084945-5867c28ba08a

replace github.com/filecoin-project/go-statestore => github.com/hunjixin/go-statestore v0.1.1-0.20211229093043-b4de7dc02a01
replace (
github.com/filecoin-project/filecoin-ffi => ./extern/filecoin-ffi
github.com/filecoin-project/go-jsonrpc => github.com/ipfs-force-community/go-jsonrpc v0.1.4-0.20210721095535-a67dff16de21
github.com/filecoin-project/go-statemachine => github.com/hunjixin/go-statemachine v0.0.0-20220110084945-5867c28ba08a
github.com/filecoin-project/go-statestore => github.com/hunjixin/go-statestore v0.1.1-0.20211229093043-b4de7dc02a01
github.com/ipfs/go-ipfs-cmds => github.com/ipfs-force-community/go-ipfs-cmds v0.6.1-0.20210521090123-4587df7fa0ab
)
62 changes: 7 additions & 55 deletions go.sum

Large diffs are not rendered by default.

11 changes: 0 additions & 11 deletions market_client/market_client.go

This file was deleted.

17 changes: 8 additions & 9 deletions market_client/market_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package market_client
import (
"context"
"encoding/json"
gwapi0 "github.com/filecoin-project/venus/venus-shared/api/gateway/v0"
types3 "github.com/filecoin-project/venus/venus-shared/types"
"github.com/filecoin-project/venus/venus-shared/types/gateway"
"time"
Expand All @@ -16,8 +17,6 @@ import (
"github.com/filecoin-project/venus-sealer/sector-storage/storiface"
types2 "github.com/filecoin-project/venus-sealer/types"

"github.com/ipfs-force-community/venus-gateway/marketevent"
"github.com/ipfs-force-community/venus-gateway/types"
logging "github.com/ipfs/go-log/v2"

"github.com/filecoin-project/venus-market/piecestorage"
Expand All @@ -30,8 +29,8 @@ import (
var log = logging.Logger("market_event")

type MarketEvent struct {
client IMarketEventClient
mAddr types2.MinerAddress
client gwapi0.IMarketServiceProvider
mAddr types2.MinerAddress
stor *stores.Remote
sectorBlocks *sectorblocks.SectorBlocks
storageMgr *sectorstorage.Manager
Expand Down Expand Up @@ -73,14 +72,14 @@ func (e *MarketEvent) listenMarketRequestOnce(ctx context.Context) error {
for marketEvent := range marketEventCh {
switch marketEvent.Method {
case "InitConnect":
req := types.ConnectedCompleted{}
req := gateway.ConnectedCompleted{}
err := json.Unmarshal(marketEvent.Payload, &req)
if err != nil {
return xerrors.Errorf("odd error in connect %v", err)
}
log.Infof("success to connect with market %s", req.ChannelId)
case "IsUnsealed":
req := marketevent.IsUnsealRequest{}
req := gateway.IsUnsealRequest{}
err := json.Unmarshal(marketEvent.Payload, &req)
if err != nil {
_ = e.client.ResponseMarketEvent(ctx, &gateway.ResponseEvent{
Expand All @@ -92,7 +91,7 @@ func (e *MarketEvent) listenMarketRequestOnce(ctx context.Context) error {
}
e.processIsUnsealed(ctx, marketEvent.ID, req)
case "SectorsUnsealPiece":
req := marketevent.UnsealRequest{}
req := gateway.UnsealRequest{}
err := json.Unmarshal(marketEvent.Payload, &req)
if err != nil {
_ = e.client.ResponseMarketEvent(ctx, &gateway.ResponseEvent{
Expand All @@ -111,7 +110,7 @@ func (e *MarketEvent) listenMarketRequestOnce(ctx context.Context) error {
return nil
}

func (e *MarketEvent) processIsUnsealed(ctx context.Context, reqId types3.UUID, req marketevent.IsUnsealRequest) {
func (e *MarketEvent) processIsUnsealed(ctx context.Context, reqId types3.UUID, req gateway.IsUnsealRequest) {
has, err := e.stor.CheckIsUnsealed(ctx, req.Sector, abi.PaddedPieceSize(req.Offset), req.Size)
if err != nil {
e.error(ctx, reqId, err)
Expand All @@ -121,7 +120,7 @@ func (e *MarketEvent) processIsUnsealed(ctx context.Context, reqId types3.UUID,
e.val(ctx, reqId, has)
}

func (e *MarketEvent) processSectorUnsealed(ctx context.Context, reqId types3.UUID, req marketevent.UnsealRequest) {
func (e *MarketEvent) processSectorUnsealed(ctx context.Context, reqId types3.UUID, req gateway.UnsealRequest) {
sectorInfo, err := e.sectorBlocks.GetSectorInfo(req.Sector.ID.Number)
if err != nil {
e.error(ctx, reqId, err)
Expand Down
5 changes: 3 additions & 2 deletions market_client/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"github.com/filecoin-project/venus-market/piecestorage"
"github.com/filecoin-project/venus-sealer/proof_client"
gwapi0 "github.com/filecoin-project/venus/venus-shared/api/gateway/v0"
"github.com/filecoin-project/venus/venus-shared/api/market"
xerrors "github.com/pkg/errors"
"go.uber.org/fx"
Expand All @@ -15,14 +16,14 @@ import (
"github.com/filecoin-project/venus-sealer/types"
)

type MarketEventClientSets map[string]IMarketEventClient
type MarketEventClientSets map[string]gwapi0.IMarketServiceProvider

func NewMarketEvents(gatewayEvents proof_client.GatewayClientSets,
mrgCfg *config.RegisterMarketConfig,
nodeConfig *config.MarketNodeConfig,
marketNode market.IMarket) (MarketEventClientSets, error) {

var marketClients = make(map[string]IMarketEventClient)
var marketClients = make(map[string]gwapi0.IMarketServiceProvider)

if len(mrgCfg.Urls) == 0 { // RegisterMarket is not set in configurations, use all
for url, client := range gatewayEvents {
Expand Down
6 changes: 0 additions & 6 deletions proof_client/proof_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,11 @@ package proof_client
import (
"context"
gwapi0 "github.com/filecoin-project/venus/venus-shared/api/gateway/v0"
gtypes "github.com/filecoin-project/venus/venus-shared/types/gateway"
"github.com/ipfs-force-community/venus-common-utils/apiinfo"
xerrors "github.com/pkg/errors"
"go.uber.org/fx"
)

type IProofEventClient interface {
ResponseProofEvent(ctx context.Context, resp *gtypes.ResponseEvent) error
ListenProofEvent(ctx context.Context, policy *gtypes.ProofRegisterPolicy) (<-chan *gtypes.RequestEvent, error)
}

func newGateway(lc fx.Lifecycle, ctx context.Context, url, token string) (gwapi0.IGateway, error) {
apiInfo := apiinfo.APIInfo{
Addr: url,
Expand Down
11 changes: 5 additions & 6 deletions proof_client/proof_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package proof_client
import (
"context"
"encoding/json"
gateway2 "github.com/filecoin-project/venus/venus-shared/api/gateway/v0"
types3 "github.com/filecoin-project/venus/venus-shared/types"
"github.com/filecoin-project/venus/venus-shared/types/gateway"
"time"
Expand All @@ -13,15 +14,13 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/venus-sealer/storage"
types2 "github.com/filecoin-project/venus-sealer/types"

"github.com/ipfs-force-community/venus-gateway/types"
)

var log = logging.Logger("proof_event")

type ProofEvent struct {
prover storage.WinningPoStProver
client IProofEventClient
client gateway2.IProofServiceProvider
mAddr types2.MinerAddress
}

Expand Down Expand Up @@ -59,14 +58,14 @@ func (e *ProofEvent) listenProofRequestOnce(ctx context.Context) error {
for proofEvent := range proofEventCh {
switch proofEvent.Method {
case "InitConnect":
req := types.ConnectedCompleted{}
req := gateway.ConnectedCompleted{}
err := json.Unmarshal(proofEvent.Payload, &req)
if err != nil {
return xerrors.Errorf("odd error in connect %v", err)
}
log.Infof("success to connect with proof %s", req.ChannelId)
case "ComputeProof":
req := types.ComputeProofRequest{}
req := gateway.ComputeProofRequest{}
err := json.Unmarshal(proofEvent.Payload, &req)
if err != nil {
_ = e.client.ResponseProofEvent(ctx, &gateway.ResponseEvent{
Expand All @@ -86,7 +85,7 @@ func (e *ProofEvent) listenProofRequestOnce(ctx context.Context) error {
}

// context.Context, []builtin.ExtendedSectorInfo, abi.PoStRandomness, abi.ChainEpoch, network.Version
func (e *ProofEvent) processComputeProof(ctx context.Context, reqId types3.UUID, req types.ComputeProofRequest) {
func (e *ProofEvent) processComputeProof(ctx context.Context, reqId types3.UUID, req gateway.ComputeProofRequest) {
proof, err := e.prover.ComputeProof(ctx, req.SectorInfos, req.Rand, req.Height, req.NWVersion)
if err != nil {
_ = e.client.ResponseProofEvent(ctx, &gateway.ResponseEvent{
Expand Down
Loading