lpdeal: Make booster- retrievals work
This commit is contained in:
parent
e0f84087ac
commit
648ac7adaf
@ -4,6 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/filecoin-project/lotus/metrics/proxy"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -535,7 +536,9 @@ var lpBoostProxyCmd = &cli.Command{
|
|||||||
color.Green("%s served %.3f MiB in %s (%.2f MiB/s)", pieceCid, float64(n)/(1024*1024), took, mbps)
|
color.Green("%s served %.3f MiB in %s (%.2f MiB/s)", pieceCid, float64(n)/(1024*1024), took, mbps)
|
||||||
}
|
}
|
||||||
|
|
||||||
mh, err := node.MinerHandler(&ast, false) // todo permissioned
|
finalApi := proxy.LoggingAPI[api.StorageMiner, api.StorageMinerStruct](&ast)
|
||||||
|
|
||||||
|
mh, err := node.MinerHandler(finalApi, false) // todo permissioned
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,10 @@ package proxy
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
|
logging "github.com/ipfs/go-log/v2"
|
||||||
"go.opencensus.io/tag"
|
"go.opencensus.io/tag"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
@ -69,3 +71,41 @@ func proxy(in interface{}, outstr interface{}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var log = logging.Logger("api_proxy")
|
||||||
|
|
||||||
|
func LoggingAPI[T, P any](a T) *P {
|
||||||
|
var out P
|
||||||
|
logProxy(a, &out)
|
||||||
|
return &out
|
||||||
|
}
|
||||||
|
|
||||||
|
func logProxy(in interface{}, outstr interface{}) {
|
||||||
|
outs := api.GetInternalStructs(outstr)
|
||||||
|
for _, out := range outs {
|
||||||
|
rint := reflect.ValueOf(out).Elem()
|
||||||
|
ra := reflect.ValueOf(in)
|
||||||
|
|
||||||
|
for f := 0; f < rint.NumField(); f++ {
|
||||||
|
field := rint.Type().Field(f)
|
||||||
|
fn := ra.MethodByName(field.Name)
|
||||||
|
|
||||||
|
rint.Field(f).Set(reflect.MakeFunc(field.Type, func(args []reflect.Value) (results []reflect.Value) {
|
||||||
|
var wargs []interface{}
|
||||||
|
wargs = append(wargs, "method", field.Name)
|
||||||
|
|
||||||
|
for i := 1; i < len(args); i++ {
|
||||||
|
wargs = append(wargs, fmt.Sprintf("arg%d", i), args[i].Interface())
|
||||||
|
}
|
||||||
|
|
||||||
|
res := fn.Call(args)
|
||||||
|
for i, r := range res {
|
||||||
|
wargs = append(wargs, fmt.Sprintf("ret%d", i), r.Interface())
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debugw("APICALL", wargs...)
|
||||||
|
return res
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -3,6 +3,8 @@ package fakelm
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
"github.com/filecoin-project/go-state-types/network"
|
||||||
|
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
@ -96,6 +98,11 @@ func (l *LMRPCProvider) SectorsStatus(ctx context.Context, sid abi.SectorNumber,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
spt, err := miner.SealProofTypeFromSectorSize(l.ssize, network.Version20, false) // good enough, just need this for ssize anyways
|
||||||
|
if err != nil {
|
||||||
|
return api.SectorInfo{}, err
|
||||||
|
}
|
||||||
|
|
||||||
if len(si) == 0 {
|
if len(si) == 0 {
|
||||||
state := api.SectorState(sealing.UndefinedSectorState)
|
state := api.SectorState(sealing.UndefinedSectorState)
|
||||||
if len(ssip) > 0 {
|
if len(ssip) > 0 {
|
||||||
@ -119,7 +126,7 @@ func (l *LMRPCProvider) SectorsStatus(ctx context.Context, sid abi.SectorNumber,
|
|||||||
ReplicaUpdateMessage: nil,
|
ReplicaUpdateMessage: nil,
|
||||||
LastErr: "",
|
LastErr: "",
|
||||||
Log: nil,
|
Log: nil,
|
||||||
SealProof: 0,
|
SealProof: spt,
|
||||||
Activation: 0,
|
Activation: 0,
|
||||||
Expiration: 0,
|
Expiration: 0,
|
||||||
DealWeight: big.Zero(),
|
DealWeight: big.Zero(),
|
||||||
@ -154,7 +161,7 @@ func (l *LMRPCProvider) SectorsStatus(ctx context.Context, sid abi.SectorNumber,
|
|||||||
LastErr: "",
|
LastErr: "",
|
||||||
Log: nil,
|
Log: nil,
|
||||||
|
|
||||||
SealProof: 0,
|
SealProof: spt,
|
||||||
Activation: 0,
|
Activation: 0,
|
||||||
Expiration: 0,
|
Expiration: 0,
|
||||||
DealWeight: big.Zero(),
|
DealWeight: big.Zero(),
|
||||||
|
Loading…
Reference in New Issue
Block a user