Fix lotus/miner build

This commit is contained in:
Łukasz Magiera
2021-04-05 13:23:46 +02:00
parent f4e46c9003
commit deb2b90b6a
22 changed files with 93 additions and 55 deletions
+2
View File
@@ -39,6 +39,8 @@ type ChainIO interface {
ChainHasObj(context.Context, cid.Cid) (bool, error)
}
const LookbackNoLimit = abi.ChainEpoch(-1)
// FullNode API is a low-level interface to the Filecoin network full node
type FullNode interface {
Common
+2
View File
@@ -16,6 +16,8 @@ type StorageMinerStruct = api.StorageMinerStruct
type Worker = api.Worker
type WorkerStruct = api.WorkerStruct
type Wallet = api.Wallet
func PermissionedStorMinerAPI(a StorageMiner) StorageMiner {
return api.PermissionedStorMinerAPI(a)
}
+21
View File
@@ -0,0 +1,21 @@
package api
import "reflect"
// Wrap adapts partial api impl to another version
// proxyT is the proxy type used as input in wrapperT
// Usage: Wrap(new(v1api.FullNodeStruct), new(v0api.WrapperV1Full), eventsApi).(EventAPI)
func Wrap(proxyT, wrapperT, impl interface{}) interface{} {
proxy := reflect.New(reflect.TypeOf(proxyT).Elem())
proxyMethods := proxy.FieldByName("Internal")
ri := reflect.ValueOf(impl)
for i := 0; i < ri.NumMethod(); i++ {
mt := ri.Type().Method(i)
proxyMethods.FieldByName(mt.Name).Set(ri.Method(i))
}
wp := reflect.New(reflect.TypeOf(wrapperT).Elem())
wp.Field(0).Set(proxy)
return wp.Interface()
}