-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5150 from filecoin-project/api/add_Version
api: 各组件增加Version接口/add Version api for components
- Loading branch information
Showing
49 changed files
with
556 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package common | ||
|
||
import ( | ||
"context" | ||
|
||
apiwrapper "github.com/filecoin-project/venus/app/submodule/common/v0api" | ||
"github.com/filecoin-project/venus/pkg/constants" | ||
"github.com/filecoin-project/venus/venus-shared/api/chain" | ||
v0api "github.com/filecoin-project/venus/venus-shared/api/chain/v0" | ||
v1api "github.com/filecoin-project/venus/venus-shared/api/chain/v1" | ||
"github.com/filecoin-project/venus/venus-shared/types" | ||
) | ||
|
||
var _ v1api.ICommon = (*CommonModule)(nil) | ||
|
||
type CommonModule struct{} // nolint | ||
|
||
func NewCommonModule() *CommonModule { | ||
return new(CommonModule) | ||
} | ||
|
||
func (cm *CommonModule) Version(ctx context.Context) (types.Version, error) { | ||
return types.Version{ | ||
Version: constants.UserVersion(), | ||
APIVersion: chain.FullAPIVersion1, | ||
}, nil | ||
} | ||
|
||
func (cm *CommonModule) API() v1api.ICommon { | ||
return cm | ||
} | ||
|
||
func (cm *CommonModule) V0API() v0api.ICommon { | ||
return &apiwrapper.WrapperV1ICommon{ICommon: cm} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package v0api | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/filecoin-project/venus/venus-shared/api/chain" | ||
v0api "github.com/filecoin-project/venus/venus-shared/api/chain/v0" | ||
v1api "github.com/filecoin-project/venus/venus-shared/api/chain/v1" | ||
"github.com/filecoin-project/venus/venus-shared/types" | ||
) | ||
|
||
var _ v0api.ICommon = (*WrapperV1ICommon)(nil) | ||
|
||
type WrapperV1ICommon struct { //nolint | ||
v1api.ICommon | ||
} | ||
|
||
func (a *WrapperV1ICommon) Version(ctx context.Context) (types.Version, error) { | ||
ver, err := a.ICommon.Version(ctx) | ||
if err != nil { | ||
return types.Version{}, err | ||
} | ||
|
||
ver.APIVersion = chain.FullAPIVersion0 | ||
|
||
return ver, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package api | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/filecoin-project/venus/venus-shared/types" | ||
) | ||
|
||
type Version interface { | ||
// Version provides information about API provider | ||
Version(ctx context.Context) (types.Version, error) //perm:read | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package v0 | ||
|
||
import "github.com/filecoin-project/venus/venus-shared/api" | ||
|
||
type ICommon interface { | ||
api.Version | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,5 @@ type FullNode interface { | |
IPaychan | ||
ISyncer | ||
IWallet | ||
ICommon | ||
} |
Oops, something went wrong.