api: Split api files
This commit is contained in:
parent
02c3be9099
commit
080a84970c
52
api/api_common.go
Normal file
52
api/api_common.go
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/libp2p/go-libp2p-core/network"
|
||||||
|
"github.com/libp2p/go-libp2p-core/peer"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/build"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Common interface {
|
||||||
|
// Auth
|
||||||
|
AuthVerify(ctx context.Context, token string) ([]Permission, error)
|
||||||
|
AuthNew(ctx context.Context, perms []Permission) ([]byte, error)
|
||||||
|
|
||||||
|
// network
|
||||||
|
|
||||||
|
NetConnectedness(context.Context, peer.ID) (network.Connectedness, error)
|
||||||
|
NetPeers(context.Context) ([]peer.AddrInfo, error)
|
||||||
|
NetConnect(context.Context, peer.AddrInfo) error
|
||||||
|
NetAddrsListen(context.Context) (peer.AddrInfo, error)
|
||||||
|
NetDisconnect(context.Context, peer.ID) error
|
||||||
|
|
||||||
|
// ID returns peerID of libp2p node backing this API
|
||||||
|
ID(context.Context) (peer.ID, error)
|
||||||
|
|
||||||
|
// Version provides information about API provider
|
||||||
|
Version(context.Context) (Version, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Version provides various build-time information
|
||||||
|
type Version struct {
|
||||||
|
Version string
|
||||||
|
|
||||||
|
// APIVersion is a binary encoded semver version of the remote implementing
|
||||||
|
// this api
|
||||||
|
//
|
||||||
|
// See APIVersion in build/version.go
|
||||||
|
APIVersion uint32
|
||||||
|
|
||||||
|
// TODO: git commit / os / genesis cid?
|
||||||
|
|
||||||
|
// Seconds
|
||||||
|
BlockDelay uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v Version) String() string {
|
||||||
|
vM, vm, vp := build.VersionInts(v.APIVersion)
|
||||||
|
return fmt.Sprintf("%s+api%d.%d.%d", v.Version, vM, vm, vp)
|
||||||
|
}
|
@ -2,46 +2,16 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
sectorbuilder "github.com/filecoin-project/go-sectorbuilder"
|
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
"github.com/ipfs/go-filestore"
|
"github.com/ipfs/go-filestore"
|
||||||
cbor "github.com/ipfs/go-ipld-cbor"
|
|
||||||
"github.com/libp2p/go-libp2p-core/network"
|
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p-core/peer"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/build"
|
|
||||||
"github.com/filecoin-project/lotus/chain/actors"
|
"github.com/filecoin-project/lotus/chain/actors"
|
||||||
"github.com/filecoin-project/lotus/chain/address"
|
"github.com/filecoin-project/lotus/chain/address"
|
||||||
"github.com/filecoin-project/lotus/chain/store"
|
"github.com/filecoin-project/lotus/chain/store"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
|
||||||
cbor.RegisterCborType(SealedRef{})
|
|
||||||
}
|
|
||||||
|
|
||||||
type Common interface {
|
|
||||||
// Auth
|
|
||||||
AuthVerify(ctx context.Context, token string) ([]Permission, error)
|
|
||||||
AuthNew(ctx context.Context, perms []Permission) ([]byte, error)
|
|
||||||
|
|
||||||
// network
|
|
||||||
|
|
||||||
NetConnectedness(context.Context, peer.ID) (network.Connectedness, error)
|
|
||||||
NetPeers(context.Context) ([]peer.AddrInfo, error)
|
|
||||||
NetConnect(context.Context, peer.AddrInfo) error
|
|
||||||
NetAddrsListen(context.Context) (peer.AddrInfo, error)
|
|
||||||
NetDisconnect(context.Context, peer.ID) error
|
|
||||||
|
|
||||||
// ID returns peerID of libp2p node backing this API
|
|
||||||
ID(context.Context) (peer.ID, error)
|
|
||||||
|
|
||||||
// Version provides information about API provider
|
|
||||||
Version(context.Context) (Version, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
// FullNode API is a low-level interface to the Filecoin network full node
|
// FullNode API is a low-level interface to the Filecoin network full node
|
||||||
type FullNode interface {
|
type FullNode interface {
|
||||||
Common
|
Common
|
||||||
@ -152,45 +122,6 @@ type FullNode interface {
|
|||||||
PaychVoucherSubmit(context.Context, address.Address, *types.SignedVoucher) (cid.Cid, error)
|
PaychVoucherSubmit(context.Context, address.Address, *types.SignedVoucher) (cid.Cid, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// StorageMiner is a low-level interface to the Filecoin network storage miner node
|
|
||||||
type StorageMiner interface {
|
|
||||||
Common
|
|
||||||
|
|
||||||
ActorAddress(context.Context) (address.Address, error)
|
|
||||||
|
|
||||||
// Temp api for testing
|
|
||||||
StoreGarbageData(context.Context) error
|
|
||||||
|
|
||||||
// Get the status of a given sector by ID
|
|
||||||
SectorsStatus(context.Context, uint64) (sectorbuilder.SectorSealingStatus, error)
|
|
||||||
|
|
||||||
// List all staged sectors
|
|
||||||
SectorsList(context.Context) ([]uint64, error)
|
|
||||||
|
|
||||||
SectorsRefs(context.Context) (map[string][]SealedRef, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Version provides various build-time information
|
|
||||||
type Version struct {
|
|
||||||
Version string
|
|
||||||
|
|
||||||
// APIVersion is a binary encoded semver version of the remote implementing
|
|
||||||
// this api
|
|
||||||
//
|
|
||||||
// See APIVersion in build/version.go
|
|
||||||
APIVersion uint32
|
|
||||||
|
|
||||||
// TODO: git commit / os / genesis cid?
|
|
||||||
|
|
||||||
// Seconds
|
|
||||||
BlockDelay uint64
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v Version) String() string {
|
|
||||||
vM, vm, vp := build.VersionInts(v.APIVersion)
|
|
||||||
return fmt.Sprintf("%s+api%d.%d.%d", v.Version, vM, vm, vp)
|
|
||||||
}
|
|
||||||
|
|
||||||
type Import struct {
|
type Import struct {
|
||||||
Status filestore.Status
|
Status filestore.Status
|
||||||
Key cid.Cid
|
Key cid.Cid
|
||||||
@ -275,12 +206,6 @@ type MinerPower struct {
|
|||||||
TotalPower types.BigInt
|
TotalPower types.BigInt
|
||||||
}
|
}
|
||||||
|
|
||||||
type SealedRef struct {
|
|
||||||
Piece string
|
|
||||||
Offset uint64
|
|
||||||
Size uint32
|
|
||||||
}
|
|
||||||
|
|
||||||
type QueryOffer struct {
|
type QueryOffer struct {
|
||||||
Err string
|
Err string
|
||||||
|
|
46
api/api_storage.go
Normal file
46
api/api_storage.go
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/chain/address"
|
||||||
|
"github.com/filecoin-project/lotus/lib/sectorbuilder"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SectorState int
|
||||||
|
|
||||||
|
const (
|
||||||
|
Undefined SectorState = iota
|
||||||
|
|
||||||
|
Empty // TODO: Is this useful
|
||||||
|
Packing // sector not in sealStore, and not on chain
|
||||||
|
|
||||||
|
Unsealed // sealing / queued
|
||||||
|
PreCommitting // on chain pre-commit
|
||||||
|
PreCommitted // waiting for seed
|
||||||
|
Committing
|
||||||
|
)
|
||||||
|
|
||||||
|
// StorageMiner is a low-level interface to the Filecoin network storage miner node
|
||||||
|
type StorageMiner interface {
|
||||||
|
Common
|
||||||
|
|
||||||
|
ActorAddress(context.Context) (address.Address, error)
|
||||||
|
|
||||||
|
// Temp api for testing
|
||||||
|
StoreGarbageData(context.Context) error
|
||||||
|
|
||||||
|
// Get the status of a given sector by ID
|
||||||
|
SectorsStatus(context.Context, uint64) (sectorbuilder.SectorSealingStatus, error)
|
||||||
|
|
||||||
|
// List all staged sectors
|
||||||
|
SectorsList(context.Context) ([]uint64, error)
|
||||||
|
|
||||||
|
SectorsRefs(context.Context) (map[string][]SealedRef, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type SealedRef struct {
|
||||||
|
Piece string
|
||||||
|
Offset uint64
|
||||||
|
Size uint32
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user