forked from ipfs-force-community/sophon-gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrpc.go
More file actions
73 lines (56 loc) · 2.24 KB
/
Copy pathrpc.go
File metadata and controls
73 lines (56 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package main
import (
"context"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/crypto"
proof5 "github.com/filecoin-project/specs-actors/v5/actors/runtime/proof"
"github.com/filecoin-project/venus-wallet/core"
"github.com/ipfs-force-community/venus-gateway/proofevent"
"github.com/ipfs-force-community/venus-gateway/walletevent"
)
type IGatewayPushAPI interface {
proofevent.IProofEvent
walletevent.IWalletEvent
}
type IGatewayAPI interface {
proofevent.IProofEventAPI
walletevent.IWalletEventAPI
IGatewayPushAPI
}
var _ IGatewayAPI = (*GatewayAPI)(nil)
type GatewayAPI struct {
proofevent.IProofEventAPI
walletevent.IWalletEventAPI
pe *proofevent.ProofEventStream
we *walletevent.WalletEventStream
}
func NewGatewayAPI(pe *proofevent.ProofEventStream, we *walletevent.WalletEventStream) *GatewayAPI {
return &GatewayAPI{
IProofEventAPI: proofevent.NewProofEventAPI(pe),
IWalletEventAPI: walletevent.NewWalletEventAPI(we),
pe: pe,
we: we,
}
}
func (g *GatewayAPI) ComputeProof(ctx context.Context, miner address.Address, sectorInfos []proof5.SectorInfo, rand abi.PoStRandomness) ([]proof5.PoStProof, error) {
return g.pe.ComputeProof(ctx, miner, sectorInfos, rand)
}
func (g *GatewayAPI) WalletHas(ctx context.Context, supportAccount string, addr address.Address) (bool, error) {
return g.we.WalletHas(ctx, supportAccount, addr)
}
func (g *GatewayAPI) WalletSign(ctx context.Context, account string, addr address.Address, toSign []byte, meta core.MsgMeta) (*crypto.Signature, error) {
return g.we.WalletSign(ctx, account, addr, toSign, meta)
}
func (g *GatewayAPI) ListConnectedMiners(ctx context.Context) ([]address.Address, error) {
return g.pe.ListConnectedMiners(ctx)
}
func (g *GatewayAPI) ListMinerConnection(ctx context.Context, addr address.Address) (*proofevent.MinerState, error) {
return g.pe.ListMinerConnection(ctx, addr)
}
func (g *GatewayAPI) ListWalletInfo(ctx context.Context) ([]*walletevent.WalletDetail, error) {
return g.we.ListWalletInfo(ctx)
}
func (g *GatewayAPI) ListWalletInfoByWallet(ctx context.Context, wallet string) (*walletevent.WalletDetail, error) {
return g.we.ListWalletInfoByWallet(ctx, wallet)
}