extract build/version to api/version, remove api package dep on build
This commit is contained in:
parent
b4ca7928f1
commit
e7a1d72ba8
@ -11,8 +11,6 @@ import (
|
|||||||
"github.com/libp2p/go-libp2p-core/network"
|
"github.com/libp2p/go-libp2p-core/network"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p-core/peer"
|
||||||
protocol "github.com/libp2p/go-libp2p-core/protocol"
|
protocol "github.com/libp2p/go-libp2p-core/protocol"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/build"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Common interface {
|
type Common interface {
|
||||||
@ -57,7 +55,7 @@ type Common interface {
|
|||||||
ID(context.Context) (peer.ID, error)
|
ID(context.Context) (peer.ID, error)
|
||||||
|
|
||||||
// Version provides information about API provider
|
// Version provides information about API provider
|
||||||
Version(context.Context) (Version, error)
|
Version(context.Context) (APIVersion, error)
|
||||||
|
|
||||||
LogList(context.Context) ([]string, error)
|
LogList(context.Context) ([]string, error)
|
||||||
LogSetLevel(context.Context, string, string) error
|
LogSetLevel(context.Context, string, string) error
|
||||||
@ -71,15 +69,15 @@ type Common interface {
|
|||||||
Closing(context.Context) (<-chan struct{}, error)
|
Closing(context.Context) (<-chan struct{}, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Version provides various build-time information
|
// APIVersion provides various build-time information
|
||||||
type Version struct {
|
type APIVersion struct {
|
||||||
Version string
|
Version string
|
||||||
|
|
||||||
// APIVersion is a binary encoded semver version of the remote implementing
|
// APIVersion is a binary encoded semver version of the remote implementing
|
||||||
// this api
|
// this api
|
||||||
//
|
//
|
||||||
// See APIVersion in build/version.go
|
// See APIVersion in build/version.go
|
||||||
APIVersion build.Version
|
APIVersion Version
|
||||||
|
|
||||||
// TODO: git commit / os / genesis cid?
|
// TODO: git commit / os / genesis cid?
|
||||||
|
|
||||||
@ -87,7 +85,7 @@ type Version struct {
|
|||||||
BlockDelay uint64
|
BlockDelay uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v Version) String() string {
|
func (v APIVersion) String() string {
|
||||||
return fmt.Sprintf("%s+api%s", v.Version, v.APIVersion.String())
|
return fmt.Sprintf("%s+api%s", v.Version, v.APIVersion.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,12 +9,10 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/extern/sector-storage/sealtasks"
|
"github.com/filecoin-project/lotus/extern/sector-storage/sealtasks"
|
||||||
"github.com/filecoin-project/lotus/extern/sector-storage/stores"
|
"github.com/filecoin-project/lotus/extern/sector-storage/stores"
|
||||||
"github.com/filecoin-project/lotus/extern/sector-storage/storiface"
|
"github.com/filecoin-project/lotus/extern/sector-storage/storiface"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/build"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type WorkerAPI interface {
|
type WorkerAPI interface {
|
||||||
Version(context.Context) (build.Version, error)
|
Version(context.Context) (Version, error)
|
||||||
// TODO: Info() (name, ...) ?
|
// TODO: Info() (name, ...) ?
|
||||||
|
|
||||||
TaskTypes(context.Context) (map[sealtasks.TaskType]struct{}, error) // TaskType -> Weight
|
TaskTypes(context.Context) (map[sealtasks.TaskType]struct{}, error) // TaskType -> Weight
|
||||||
|
@ -33,7 +33,6 @@ import (
|
|||||||
"github.com/filecoin-project/specs-storage/storage"
|
"github.com/filecoin-project/specs-storage/storage"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/build"
|
|
||||||
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
||||||
"github.com/filecoin-project/lotus/chain/actors/builtin/paych"
|
"github.com/filecoin-project/lotus/chain/actors/builtin/paych"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
@ -64,8 +63,8 @@ type CommonStruct struct {
|
|||||||
NetBlockRemove func(ctx context.Context, acl api.NetBlockList) error `perm:"admin"`
|
NetBlockRemove func(ctx context.Context, acl api.NetBlockList) error `perm:"admin"`
|
||||||
NetBlockList func(ctx context.Context) (api.NetBlockList, error) `perm:"read"`
|
NetBlockList func(ctx context.Context) (api.NetBlockList, error) `perm:"read"`
|
||||||
|
|
||||||
ID func(context.Context) (peer.ID, error) `perm:"read"`
|
ID func(context.Context) (peer.ID, error) `perm:"read"`
|
||||||
Version func(context.Context) (api.Version, error) `perm:"read"`
|
Version func(context.Context) (api.APIVersion, error) `perm:"read"`
|
||||||
|
|
||||||
LogList func(context.Context) ([]string, error) `perm:"write"`
|
LogList func(context.Context) ([]string, error) `perm:"write"`
|
||||||
LogSetLevel func(context.Context, string, string) error `perm:"write"`
|
LogSetLevel func(context.Context, string, string) error `perm:"write"`
|
||||||
@ -389,7 +388,7 @@ type WorkerStruct struct {
|
|||||||
Internal struct {
|
Internal struct {
|
||||||
// TODO: lower perms
|
// TODO: lower perms
|
||||||
|
|
||||||
Version func(context.Context) (build.Version, error) `perm:"admin"`
|
Version func(context.Context) (api.Version, error) `perm:"admin"`
|
||||||
|
|
||||||
TaskTypes func(context.Context) (map[sealtasks.TaskType]struct{}, error) `perm:"admin"`
|
TaskTypes func(context.Context) (map[sealtasks.TaskType]struct{}, error) `perm:"admin"`
|
||||||
Paths func(context.Context) ([]stores.StoragePath, error) `perm:"admin"`
|
Paths func(context.Context) ([]stores.StoragePath, error) `perm:"admin"`
|
||||||
@ -546,7 +545,7 @@ func (c *CommonStruct) ID(ctx context.Context) (peer.ID, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Version implements API.Version
|
// Version implements API.Version
|
||||||
func (c *CommonStruct) Version(ctx context.Context) (api.Version, error) {
|
func (c *CommonStruct) Version(ctx context.Context) (api.APIVersion, error) {
|
||||||
return c.Internal.Version(ctx)
|
return c.Internal.Version(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1610,7 +1609,7 @@ func (c *StorageMinerStruct) CheckProvable(ctx context.Context, pp abi.Registere
|
|||||||
|
|
||||||
// WorkerStruct
|
// WorkerStruct
|
||||||
|
|
||||||
func (w *WorkerStruct) Version(ctx context.Context) (build.Version, error) {
|
func (w *WorkerStruct) Version(ctx context.Context) (api.Version, error) {
|
||||||
return w.Internal.Version(ctx)
|
return w.Internal.Version(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,8 @@ package mocks
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
context "context"
|
context "context"
|
||||||
|
reflect "reflect"
|
||||||
|
|
||||||
address "github.com/filecoin-project/go-address"
|
address "github.com/filecoin-project/go-address"
|
||||||
bitfield "github.com/filecoin-project/go-bitfield"
|
bitfield "github.com/filecoin-project/go-bitfield"
|
||||||
datatransfer "github.com/filecoin-project/go-data-transfer"
|
datatransfer "github.com/filecoin-project/go-data-transfer"
|
||||||
@ -31,7 +33,6 @@ import (
|
|||||||
network0 "github.com/libp2p/go-libp2p-core/network"
|
network0 "github.com/libp2p/go-libp2p-core/network"
|
||||||
peer "github.com/libp2p/go-libp2p-core/peer"
|
peer "github.com/libp2p/go-libp2p-core/peer"
|
||||||
protocol "github.com/libp2p/go-libp2p-core/protocol"
|
protocol "github.com/libp2p/go-libp2p-core/protocol"
|
||||||
reflect "reflect"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// MockFullNode is a mock of FullNode interface
|
// MockFullNode is a mock of FullNode interface
|
||||||
@ -2764,10 +2765,10 @@ func (mr *MockFullNodeMockRecorder) SyncValidateTipset(arg0, arg1 interface{}) *
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Version mocks base method
|
// Version mocks base method
|
||||||
func (m *MockFullNode) Version(arg0 context.Context) (api.Version, error) {
|
func (m *MockFullNode) Version(arg0 context.Context) (api.APIVersion, error) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "Version", arg0)
|
ret := m.ctrl.Call(m, "Version", arg0)
|
||||||
ret0, _ := ret[0].(api.Version)
|
ret0, _ := ret[0].(api.APIVersion)
|
||||||
ret1, _ := ret[1].(error)
|
ret1, _ := ret[1].(error)
|
||||||
return ret0, ret1
|
return ret0, ret1
|
||||||
}
|
}
|
||||||
|
@ -155,13 +155,13 @@ var MineNext = miner.MineReq{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ts *testSuite) testVersion(t *testing.T) {
|
func (ts *testSuite) testVersion(t *testing.T) {
|
||||||
build.RunningNodeType = build.NodeFull
|
api.RunningNodeType = api.NodeFull
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
apis, _ := ts.makeNodes(t, OneFull, OneMiner)
|
apis, _ := ts.makeNodes(t, OneFull, OneMiner)
|
||||||
api := apis[0]
|
napi := apis[0]
|
||||||
|
|
||||||
v, err := api.Version(ctx)
|
v, err := napi.Version(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
71
api/version.go
Normal file
71
api/version.go
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
xerrors "golang.org/x/xerrors"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Version uint32
|
||||||
|
|
||||||
|
func newVer(major, minor, patch uint8) Version {
|
||||||
|
return Version(uint32(major)<<16 | uint32(minor)<<8 | uint32(patch))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ints returns (major, minor, patch) versions
|
||||||
|
func (ve Version) Ints() (uint32, uint32, uint32) {
|
||||||
|
v := uint32(ve)
|
||||||
|
return (v & majorOnlyMask) >> 16, (v & minorOnlyMask) >> 8, v & patchOnlyMask
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ve Version) String() string {
|
||||||
|
vmj, vmi, vp := ve.Ints()
|
||||||
|
return fmt.Sprintf("%d.%d.%d", vmj, vmi, vp)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ve Version) EqMajorMinor(v2 Version) bool {
|
||||||
|
return ve&minorMask == v2&minorMask
|
||||||
|
}
|
||||||
|
|
||||||
|
type NodeType int
|
||||||
|
|
||||||
|
const (
|
||||||
|
NodeUnknown NodeType = iota
|
||||||
|
|
||||||
|
NodeFull
|
||||||
|
NodeMiner
|
||||||
|
NodeWorker
|
||||||
|
)
|
||||||
|
|
||||||
|
var RunningNodeType NodeType
|
||||||
|
|
||||||
|
func VersionForType(nodeType NodeType) (Version, error) {
|
||||||
|
switch nodeType {
|
||||||
|
case NodeFull:
|
||||||
|
return FullAPIVersion, nil
|
||||||
|
case NodeMiner:
|
||||||
|
return MinerAPIVersion, nil
|
||||||
|
case NodeWorker:
|
||||||
|
return WorkerAPIVersion, nil
|
||||||
|
default:
|
||||||
|
return Version(0), xerrors.Errorf("unknown node type %d", nodeType)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// semver versions of the rpc api exposed
|
||||||
|
var (
|
||||||
|
FullAPIVersion = newVer(1, 1, 0)
|
||||||
|
MinerAPIVersion = newVer(1, 0, 1)
|
||||||
|
WorkerAPIVersion = newVer(1, 0, 0)
|
||||||
|
)
|
||||||
|
|
||||||
|
//nolint:varcheck,deadcode
|
||||||
|
const (
|
||||||
|
majorMask = 0xff0000
|
||||||
|
minorMask = 0xffff00
|
||||||
|
patchMask = 0xffffff
|
||||||
|
|
||||||
|
majorOnlyMask = 0xff0000
|
||||||
|
minorOnlyMask = 0x00ff00
|
||||||
|
patchOnlyMask = 0x0000ff
|
||||||
|
)
|
@ -1,11 +1,5 @@
|
|||||||
package build
|
package build
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"golang.org/x/xerrors"
|
|
||||||
)
|
|
||||||
|
|
||||||
var CurrentCommit string
|
var CurrentCommit string
|
||||||
var BuildType int
|
var BuildType int
|
||||||
|
|
||||||
@ -40,67 +34,3 @@ const BuildVersion = "1.5.0"
|
|||||||
func UserVersion() string {
|
func UserVersion() string {
|
||||||
return BuildVersion + buildType() + CurrentCommit
|
return BuildVersion + buildType() + CurrentCommit
|
||||||
}
|
}
|
||||||
|
|
||||||
type Version uint32
|
|
||||||
|
|
||||||
func newVer(major, minor, patch uint8) Version {
|
|
||||||
return Version(uint32(major)<<16 | uint32(minor)<<8 | uint32(patch))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ints returns (major, minor, patch) versions
|
|
||||||
func (ve Version) Ints() (uint32, uint32, uint32) {
|
|
||||||
v := uint32(ve)
|
|
||||||
return (v & majorOnlyMask) >> 16, (v & minorOnlyMask) >> 8, v & patchOnlyMask
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ve Version) String() string {
|
|
||||||
vmj, vmi, vp := ve.Ints()
|
|
||||||
return fmt.Sprintf("%d.%d.%d", vmj, vmi, vp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ve Version) EqMajorMinor(v2 Version) bool {
|
|
||||||
return ve&minorMask == v2&minorMask
|
|
||||||
}
|
|
||||||
|
|
||||||
type NodeType int
|
|
||||||
|
|
||||||
const (
|
|
||||||
NodeUnknown NodeType = iota
|
|
||||||
|
|
||||||
NodeFull
|
|
||||||
NodeMiner
|
|
||||||
NodeWorker
|
|
||||||
)
|
|
||||||
|
|
||||||
var RunningNodeType NodeType
|
|
||||||
|
|
||||||
func VersionForType(nodeType NodeType) (Version, error) {
|
|
||||||
switch nodeType {
|
|
||||||
case NodeFull:
|
|
||||||
return FullAPIVersion, nil
|
|
||||||
case NodeMiner:
|
|
||||||
return MinerAPIVersion, nil
|
|
||||||
case NodeWorker:
|
|
||||||
return WorkerAPIVersion, nil
|
|
||||||
default:
|
|
||||||
return Version(0), xerrors.Errorf("unknown node type %d", nodeType)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// semver versions of the rpc api exposed
|
|
||||||
var (
|
|
||||||
FullAPIVersion = newVer(1, 1, 0)
|
|
||||||
MinerAPIVersion = newVer(1, 0, 1)
|
|
||||||
WorkerAPIVersion = newVer(1, 0, 0)
|
|
||||||
)
|
|
||||||
|
|
||||||
//nolint:varcheck,deadcode
|
|
||||||
const (
|
|
||||||
majorMask = 0xff0000
|
|
||||||
minorMask = 0xffff00
|
|
||||||
patchMask = 0xffffff
|
|
||||||
|
|
||||||
majorOnlyMask = 0xff0000
|
|
||||||
minorOnlyMask = 0x00ff00
|
|
||||||
patchOnlyMask = 0x0000ff
|
|
||||||
)
|
|
||||||
|
@ -34,7 +34,7 @@ var (
|
|||||||
// gatewayDepsAPI defines the API methods that the GatewayAPI depends on
|
// gatewayDepsAPI defines the API methods that the GatewayAPI depends on
|
||||||
// (to make it easy to mock for tests)
|
// (to make it easy to mock for tests)
|
||||||
type gatewayDepsAPI interface {
|
type gatewayDepsAPI interface {
|
||||||
Version(context.Context) (api.Version, error)
|
Version(context.Context) (api.APIVersion, error)
|
||||||
ChainGetBlockMessages(context.Context, cid.Cid) (*api.BlockMessages, error)
|
ChainGetBlockMessages(context.Context, cid.Cid) (*api.BlockMessages, error)
|
||||||
ChainGetMessage(ctx context.Context, mc cid.Cid) (*types.Message, error)
|
ChainGetMessage(ctx context.Context, mc cid.Cid) (*types.Message, error)
|
||||||
ChainGetNode(ctx context.Context, p string) (*api.IpldObject, error)
|
ChainGetNode(ctx context.Context, p string) (*api.IpldObject, error)
|
||||||
@ -130,7 +130,7 @@ func (a *GatewayAPI) checkTimestamp(at time.Time) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *GatewayAPI) Version(ctx context.Context) (api.Version, error) {
|
func (a *GatewayAPI) Version(ctx context.Context) (api.APIVersion, error) {
|
||||||
return a.api.Version(ctx)
|
return a.api.Version(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ const FlagWorkerRepo = "worker-repo"
|
|||||||
const FlagWorkerRepoDeprecation = "workerrepo"
|
const FlagWorkerRepoDeprecation = "workerrepo"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
build.RunningNodeType = build.NodeWorker
|
api.RunningNodeType = api.NodeWorker
|
||||||
|
|
||||||
lotuslog.SetupLogLevels()
|
lotuslog.SetupLogLevels()
|
||||||
|
|
||||||
@ -211,8 +211,8 @@ var runCmd = &cli.Command{
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if v.APIVersion != build.MinerAPIVersion {
|
if v.APIVersion != api.MinerAPIVersion {
|
||||||
return xerrors.Errorf("lotus-miner API version doesn't match: expected: %s", api.Version{APIVersion: build.MinerAPIVersion})
|
return xerrors.Errorf("lotus-miner API version doesn't match: expected: %s", api.APIVersion{APIVersion: api.MinerAPIVersion})
|
||||||
}
|
}
|
||||||
log.Infof("Remote version %s", v)
|
log.Infof("Remote version %s", v)
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/mitchellh/go-homedir"
|
"github.com/mitchellh/go-homedir"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/api"
|
||||||
sectorstorage "github.com/filecoin-project/lotus/extern/sector-storage"
|
sectorstorage "github.com/filecoin-project/lotus/extern/sector-storage"
|
||||||
"github.com/filecoin-project/lotus/extern/sector-storage/stores"
|
"github.com/filecoin-project/lotus/extern/sector-storage/stores"
|
||||||
"github.com/filecoin-project/lotus/extern/sector-storage/storiface"
|
"github.com/filecoin-project/lotus/extern/sector-storage/storiface"
|
||||||
@ -23,8 +23,8 @@ type worker struct {
|
|||||||
disabled int64
|
disabled int64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *worker) Version(context.Context) (build.Version, error) {
|
func (w *worker) Version(context.Context) (api.Version, error) {
|
||||||
return build.WorkerAPIVersion, nil
|
return api.WorkerAPIVersion, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *worker) StorageAddLocal(ctx context.Context, path string) error {
|
func (w *worker) StorageAddLocal(ctx context.Context, path string) error {
|
||||||
|
@ -17,6 +17,7 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/go-state-types/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/api/test"
|
"github.com/filecoin-project/lotus/api/test"
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
"github.com/filecoin-project/lotus/chain/actors/policy"
|
"github.com/filecoin-project/lotus/chain/actors/policy"
|
||||||
@ -70,7 +71,7 @@ func TestWorkerKeyChange(t *testing.T) {
|
|||||||
"testnode-storage": sn[0],
|
"testnode-storage": sn[0],
|
||||||
}
|
}
|
||||||
app.Writer = output
|
app.Writer = output
|
||||||
build.RunningNodeType = build.NodeMiner
|
api.RunningNodeType = api.NodeMiner
|
||||||
|
|
||||||
fs := flag.NewFlagSet("", flag.ContinueOnError)
|
fs := flag.NewFlagSet("", flag.ContinueOnError)
|
||||||
for _, f := range cmd.Flags {
|
for _, f := range cmd.Flags {
|
||||||
|
@ -11,8 +11,8 @@ import (
|
|||||||
|
|
||||||
"github.com/filecoin-project/go-state-types/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/api/test"
|
"github.com/filecoin-project/lotus/api/test"
|
||||||
"github.com/filecoin-project/lotus/build"
|
|
||||||
"github.com/filecoin-project/lotus/chain/actors/policy"
|
"github.com/filecoin-project/lotus/chain/actors/policy"
|
||||||
"github.com/filecoin-project/lotus/lib/lotuslog"
|
"github.com/filecoin-project/lotus/lib/lotuslog"
|
||||||
"github.com/filecoin-project/lotus/node/repo"
|
"github.com/filecoin-project/lotus/node/repo"
|
||||||
@ -55,7 +55,7 @@ func TestMinerAllInfo(t *testing.T) {
|
|||||||
"testnode-full": n[0],
|
"testnode-full": n[0],
|
||||||
"testnode-storage": sn[0],
|
"testnode-storage": sn[0],
|
||||||
}
|
}
|
||||||
build.RunningNodeType = build.NodeMiner
|
api.RunningNodeType = api.NodeMiner
|
||||||
|
|
||||||
cctx := cli.NewContext(app, flag.NewFlagSet("", flag.ContinueOnError), nil)
|
cctx := cli.NewContext(app, flag.NewFlagSet("", flag.ContinueOnError), nil)
|
||||||
|
|
||||||
|
@ -12,6 +12,8 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
cliutil "github.com/filecoin-project/lotus/cli/util"
|
||||||
|
|
||||||
"github.com/docker/go-units"
|
"github.com/docker/go-units"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/ipfs/go-datastore"
|
"github.com/ipfs/go-datastore"
|
||||||
@ -186,8 +188,8 @@ var initCmd = &cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !v.APIVersion.EqMajorMinor(build.FullAPIVersion) {
|
if !v.APIVersion.EqMajorMinor(lapi.FullAPIVersion) {
|
||||||
return xerrors.Errorf("Remote API version didn't match (expected %s, remote %s)", build.FullAPIVersion, v.APIVersion)
|
return xerrors.Errorf("Remote API version didn't match (expected %s, remote %s)", lapi.FullAPIVersion, v.APIVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info("Initializing repo")
|
log.Info("Initializing repo")
|
||||||
|
@ -18,9 +18,11 @@ import (
|
|||||||
paramfetch "github.com/filecoin-project/go-paramfetch"
|
paramfetch "github.com/filecoin-project/go-paramfetch"
|
||||||
"github.com/filecoin-project/go-state-types/big"
|
"github.com/filecoin-project/go-state-types/big"
|
||||||
|
|
||||||
|
lapi "github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
lcli "github.com/filecoin-project/lotus/cli"
|
lcli "github.com/filecoin-project/lotus/cli"
|
||||||
|
cliutil "github.com/filecoin-project/lotus/cli/util"
|
||||||
"github.com/filecoin-project/lotus/extern/sector-storage/stores"
|
"github.com/filecoin-project/lotus/extern/sector-storage/stores"
|
||||||
"github.com/filecoin-project/lotus/lib/backupds"
|
"github.com/filecoin-project/lotus/lib/backupds"
|
||||||
"github.com/filecoin-project/lotus/node/config"
|
"github.com/filecoin-project/lotus/node/config"
|
||||||
@ -68,8 +70,8 @@ var initRestoreCmd = &cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !v.APIVersion.EqMajorMinor(build.FullAPIVersion) {
|
if !v.APIVersion.EqMajorMinor(lapi.FullAPIVersion) {
|
||||||
return xerrors.Errorf("Remote API version didn't match (expected %s, remote %s)", build.FullAPIVersion, v.APIVersion)
|
return xerrors.Errorf("Remote API version didn't match (expected %s, remote %s)", lapi.FullAPIVersion, v.APIVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !cctx.Bool("nosync") {
|
if !cctx.Bool("nosync") {
|
||||||
|
@ -26,7 +26,7 @@ const FlagMinerRepo = "miner-repo"
|
|||||||
const FlagMinerRepoDeprecation = "storagerepo"
|
const FlagMinerRepoDeprecation = "storagerepo"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
build.RunningNodeType = build.NodeMiner
|
api.RunningNodeType = api.NodeMiner
|
||||||
|
|
||||||
lotuslog.SetupLogLevels()
|
lotuslog.SetupLogLevels()
|
||||||
|
|
||||||
|
@ -9,6 +9,8 @@ import (
|
|||||||
"os/signal"
|
"os/signal"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
|
cliutil "github.com/filecoin-project/lotus/cli/util"
|
||||||
|
|
||||||
mux "github.com/gorilla/mux"
|
mux "github.com/gorilla/mux"
|
||||||
"github.com/multiformats/go-multiaddr"
|
"github.com/multiformats/go-multiaddr"
|
||||||
manet "github.com/multiformats/go-multiaddr/net"
|
manet "github.com/multiformats/go-multiaddr/net"
|
||||||
@ -95,8 +97,8 @@ var runCmd = &cli.Command{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if v.APIVersion != build.FullAPIVersion {
|
if v.APIVersion != api.FullAPIVersion {
|
||||||
return xerrors.Errorf("lotus-daemon API version doesn't match: expected: %s", api.Version{APIVersion: build.FullAPIVersion})
|
return xerrors.Errorf("lotus-daemon API version doesn't match: expected: %s", api.APIVersion{APIVersion: api.FullAPIVersion})
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info("Checking full node sync status")
|
log.Info("Checking full node sync status")
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
"go.opencensus.io/trace"
|
"go.opencensus.io/trace"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
lcli "github.com/filecoin-project/lotus/cli"
|
lcli "github.com/filecoin-project/lotus/cli"
|
||||||
"github.com/filecoin-project/lotus/lib/lotuslog"
|
"github.com/filecoin-project/lotus/lib/lotuslog"
|
||||||
@ -16,7 +17,7 @@ import (
|
|||||||
var AdvanceBlockCmd *cli.Command
|
var AdvanceBlockCmd *cli.Command
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
build.RunningNodeType = build.NodeFull
|
api.RunningNodeType = api.NodeFull
|
||||||
|
|
||||||
lotuslog.SetupLogLevels()
|
lotuslog.SetupLogLevels()
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ func runSimulateCmd(_ *cli.Context) error {
|
|||||||
version, err := FullAPI.Version(ctx)
|
version, err := FullAPI.Version(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("failed to get node version: %s; falling back to unknown", err)
|
log.Printf("failed to get node version: %s; falling back to unknown", err)
|
||||||
version = api.Version{}
|
version = api.APIVersion{}
|
||||||
}
|
}
|
||||||
|
|
||||||
nv, err := FullAPI.StateNetworkVersion(ctx, ts.Key())
|
nv, err := FullAPI.StateNetworkVersion(ctx, ts.Key())
|
||||||
|
@ -179,13 +179,13 @@ func (a *CommonAPI) ID(context.Context) (peer.ID, error) {
|
|||||||
return a.Host.ID(), nil
|
return a.Host.ID(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *CommonAPI) Version(context.Context) (api.Version, error) {
|
func (a *CommonAPI) Version(context.Context) (api.APIVersion, error) {
|
||||||
v, err := build.VersionForType(build.RunningNodeType)
|
v, err := api.VersionForType(api.RunningNodeType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return api.Version{}, err
|
return api.APIVersion{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return api.Version{
|
return api.APIVersion{
|
||||||
Version: build.UserVersion(),
|
Version: build.UserVersion(),
|
||||||
APIVersion: v,
|
APIVersion: v,
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user