Skip to content

Commit

Permalink
chore: format code (#5424)
Browse files Browse the repository at this point in the history
  • Loading branch information
simlecode authored Oct 28, 2022
1 parent b96e0aa commit 5eb8361
Show file tree
Hide file tree
Showing 229 changed files with 902 additions and 822 deletions.
5 changes: 3 additions & 2 deletions app/node/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ func (b *Builder) build(ctx context.Context) (*Node, error) {
chainClock: b.chainClock,
}

//modules
// modules
nd.circulatiingSupplyCalculator = chain2.NewCirculatingSupplyCalculator(b.repo.Datastore(), b.genBlk.ParentStateRoot, b.repo.Config().NetworkParams.ForkUpgradeParam)

//services
// services
nd.configModule = config2.NewConfigModule(b.repo)

nd.blockstore, err = blockstore.NewBlockstoreSubmodule(ctx, (*builder)(b))
Expand Down Expand Up @@ -215,6 +215,7 @@ type ValueFromCtx struct{}
func (vfc *ValueFromCtx) AccFromCtx(ctx context.Context) (string, bool) {
return jwtclient.CtxGetName(ctx)
}

func (vfc *ValueFromCtx) HostFromCtx(ctx context.Context) (string, bool) {
return jwtclient.CtxGetTokenLocation(ctx)
}
3 changes: 1 addition & 2 deletions app/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ const APIPrefix = "/api"

// Node represents a full Filecoin node.
type Node struct {

// offlineMode, when true, disables libp2p.
offlineMode bool

Expand All @@ -64,7 +63,7 @@ type Node struct {
// It contains all persistent artifacts of the filecoin node.
repo repo.Repo

//moduls
// moduls
circulatiingSupplyCalculator chain.ICirculatingSupplyCalcualtor
//
// Core services
Expand Down
5 changes: 3 additions & 2 deletions app/node/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import (
"github.com/ipfs-force-community/metrics/ratelimit"
)

type RPCService interface {
}
type RPCService interface{}

type RPCBuilder struct {
namespace []string
Expand All @@ -28,6 +27,7 @@ func (builder *RPCBuilder) NameSpace(nameSpaece string) *RPCBuilder {
builder.namespace = append(builder.namespace, nameSpaece)
return builder
}

func (builder *RPCBuilder) AddServices(services ...RPCService) error {
for _, service := range services {
err := builder.AddService(service)
Expand All @@ -37,6 +37,7 @@ func (builder *RPCBuilder) AddServices(services ...RPCService) error {
}
return nil
}

func (builder *RPCBuilder) AddService(service RPCService) error {
methodName := "V0API"

Expand Down
12 changes: 4 additions & 8 deletions app/node/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ func TestJsonrpc(t *testing.T) {
assert.Equal(t, res.Result, "test")
}

type tmodule1 struct {
}
type tmodule1 struct{}

func (m *tmodule1) V0API() MockAPI1 { //nolint
return &mockAPI1{}
Expand All @@ -92,8 +91,7 @@ func (m *tmodule1) API() MockAPI1 { //nolint
return &mockAPI1{}
}

type tmodule2 struct {
}
type tmodule2 struct{}

func (m *tmodule2) V0API() MockAPI2 { //nolint
return &mockAPI2{}
Expand All @@ -112,17 +110,15 @@ type MockAPI1 interface {
type MockAPI2 interface {
Test2(ctx context.Context) error
}
type mockAPI1 struct {
}
type mockAPI1 struct{}

func (m *mockAPI1) Test1(ctx context.Context) (string, error) {
return "test", nil
}

var _ MockAPI2 = &mockAPI2{}

type mockAPI2 struct {
}
type mockAPI2 struct{}

func (m *mockAPI2) Test2(ctx context.Context) error {
return nil
Expand Down
6 changes: 4 additions & 2 deletions app/paths/paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import (
)

// node repo path defaults
const filPathVar = "VENUS_PATH"
const defaultRepoDir = "~/.venus"
const (
filPathVar = "VENUS_PATH"
defaultRepoDir = "~/.venus"
)

// GetRepoPath returns the path of the venus repo from a potential override
// string, the VENUS_PATH environment variable and a default of ~/.venus/repo.
Expand Down
2 changes: 1 addition & 1 deletion app/submodule/blockstore/blockstore_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (blockstoreAPI *blockstoreAPI) ChainStatObj(ctx context.Context, obj cid.Ci

var statslk sync.Mutex
var stats types.ObjStat
var collect = true
collect := true

walker := func(ctx context.Context, c cid.Cid) ([]*ipld.Link, error) {
if c.Prefix().Codec == cid.FilCommitmentSealed || c.Prefix().Codec == cid.FilCommitmentUnsealed {
Expand Down
2 changes: 1 addition & 1 deletion app/submodule/chain/chain_submodule.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func NewChainSubmodule(ctx context.Context,
repo := config.Repo()
// initialize chain store
chainStore := chain.NewStore(repo.ChainDatastore(), repo.Datastore(), config.GenesisCid(), circulatiingSupplyCalculator)
//drand
// drand
genBlk, err := chainStore.GetGenesisBlock(context.TODO())
if err != nil {
return nil, err
Expand Down
5 changes: 2 additions & 3 deletions app/submodule/chain/chaininfo_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,6 @@ func (cia *chainInfoAPI) GetEntry(ctx context.Context, height abi.ChainEpoch, ro
case <-ctx.Done():
return nil, fmt.Errorf("context timed out waiting on beacon entry to come back for round %d: %s", round, ctx.Err())
}

}

// VerifyEntry verifies that child is a valid entry if its parent is.
Expand Down Expand Up @@ -492,7 +491,7 @@ func (cia *chainInfoAPI) StateSearchMsg(ctx context.Context, from types.TipSetKe
if err != nil {
return nil, err
}
//todo add a api for head tipset directly
// todo add a api for head tipset directly
head, err := cia.chain.ChainReader.GetTipSet(ctx, from)
if err != nil {
return nil, err
Expand Down Expand Up @@ -685,7 +684,7 @@ func (cia *chainInfoAPI) StateActorCodeCIDs(ctx context.Context, nv network.Vers

cids["_manifest"] = manifestCid

var actorKeys = actors.GetBuiltinActorsKeys(actorVersion)
actorKeys := actors.GetBuiltinActorsKeys(actorVersion)
for _, name := range actorKeys {
actorCID, ok := actors.GetActorCodeID(actorVersion, name)
if !ok {
Expand Down
13 changes: 8 additions & 5 deletions app/submodule/chain/miner_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -574,8 +574,10 @@ func (msa *minerStateAPI) StateComputeDataCID(ctx context.Context, maddr address
return cid.Cid(cr.CommDs[0]), nil
}

var initialPledgeNum = big.NewInt(110)
var initialPledgeDen = big.NewInt(100)
var (
initialPledgeNum = big.NewInt(110)
initialPledgeDen = big.NewInt(100)
)

// StateMinerInitialPledgeCollateral returns the precommit deposit for the specified miner's sector
func (msa *minerStateAPI) StateMinerPreCommitDepositForPower(ctx context.Context, maddr address.Address, pci types.SectorPreCommitInfo, tsk types.TipSetKey) (big.Int, error) {
Expand Down Expand Up @@ -973,11 +975,12 @@ func (msa *minerStateAPI) StateMarketBalance(ctx context.Context, addr address.A
}

return out, nil

}

var dealProviderCollateralNum = types.NewInt(110)
var dealProviderCollateralDen = types.NewInt(100)
var (
dealProviderCollateralNum = types.NewInt(110)
dealProviderCollateralDen = types.NewInt(100)
)

// StateDealProviderCollateralBounds returns the min and max collateral a storage provider
// can issue. It takes the deal size and verified status as parameters.
Expand Down
1 change: 0 additions & 1 deletion app/submodule/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,4 @@ func TestConfigSet(t *testing.T) {
err = cfgAPI.Set("walletModule.defaultAddress", jsonBlobBadAddr)
assert.EqualError(t, err, address.ErrUnknownProtocol.Error())
})

}
1 change: 0 additions & 1 deletion app/submodule/market/market_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ func (m *marketAPI) StateMarketParticipants(ctx context.Context, tsk types.TipSe
}

err = escrow.ForEach(func(a address.Address, es abi.TokenAmount) error {

lk, err := locked.Get(a)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion app/submodule/mining/mining_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (miningAPI *MiningAPI) MinerGetBaseInfo(ctx context.Context, maddr address.
view := state.NewView(chainStore.Store(ctx), lbst)
act, err := view.LoadActor(ctx, maddr)
if errors.Is(err, types.ErrActorNotFound) {
//todo why
// todo why
view = state.NewView(chainStore.Store(ctx), ts.At(0).ParentStateRoot)
_, err := view.LoadActor(ctx, maddr)
if err != nil {
Expand Down
4 changes: 1 addition & 3 deletions app/submodule/multisig/multisig_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ func (a *multiSig) messageBuilder(ctx context.Context, from address.Address) (mu
// It takes the following params: <required number of senders>, <approving addresses>, <unlock duration>
// <initial balance>, <sender address of the create msg>, <gas price>
func (a *multiSig) MsigCreate(ctx context.Context, req uint64, addrs []address.Address, duration abi.ChainEpoch, val types.BigInt, src address.Address, gp types.BigInt) (*types.MessagePrototype, error) {

mb, err := a.messageBuilder(ctx, src)
if err != nil {
return nil, err
Expand All @@ -69,7 +68,6 @@ func (a *multiSig) MsigCreate(ctx context.Context, req uint64, addrs []address.A
}

func (a *multiSig) MsigPropose(ctx context.Context, msig address.Address, to address.Address, amt types.BigInt, src address.Address, method uint64, params []byte) (*types.MessagePrototype, error) {

mb, err := a.messageBuilder(ctx, src)
if err != nil {
return nil, err
Expand Down Expand Up @@ -210,7 +208,7 @@ func (a *multiSig) MsigGetVested(ctx context.Context, addr address.Address, star
return big.Zero(), nil
}

//LoadActor(ctx, addr, endTs)
// LoadActor(ctx, addr, endTs)
act, err := a.state.GetParentStateRootActor(ctx, endTS, addr)
if err != nil {
return types.EmptyInt, fmt.Errorf("failed to load multisig actor at end epoch: %w", err)
Expand Down
12 changes: 2 additions & 10 deletions app/submodule/multisig/v0api/multisig_v0api.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ func (a *WrapperV1IMultiSig) executePrototype(ctx context.Context, p *types.Mess

return sm.Cid(), nil
}
func (a *WrapperV1IMultiSig) MsigCreate(ctx context.Context, req uint64, addrs []address.Address, duration abi.ChainEpoch, val types.BigInt, src address.Address, gp types.BigInt) (cid.Cid, error) {

func (a *WrapperV1IMultiSig) MsigCreate(ctx context.Context, req uint64, addrs []address.Address, duration abi.ChainEpoch, val types.BigInt, src address.Address, gp types.BigInt) (cid.Cid, error) {
p, err := a.IMultiSig.MsigCreate(ctx, req, addrs, duration, val, src, gp)
if err != nil {
return cid.Undef, fmt.Errorf("creating prototype: %w", err)
Expand All @@ -39,16 +39,15 @@ func (a *WrapperV1IMultiSig) MsigCreate(ctx context.Context, req uint64, addrs [
}

func (a *WrapperV1IMultiSig) MsigPropose(ctx context.Context, msig address.Address, to address.Address, amt types.BigInt, src address.Address, method uint64, params []byte) (cid.Cid, error) {

p, err := a.IMultiSig.MsigPropose(ctx, msig, to, amt, src, method, params)
if err != nil {
return cid.Undef, fmt.Errorf("creating prototype: %w", err)
}

return a.executePrototype(ctx, p)
}
func (a *WrapperV1IMultiSig) MsigApprove(ctx context.Context, msig address.Address, txID uint64, src address.Address) (cid.Cid, error) {

func (a *WrapperV1IMultiSig) MsigApprove(ctx context.Context, msig address.Address, txID uint64, src address.Address) (cid.Cid, error) {
p, err := a.IMultiSig.MsigApprove(ctx, msig, txID, src)
if err != nil {
return cid.Undef, fmt.Errorf("creating prototype: %w", err)
Expand Down Expand Up @@ -85,7 +84,6 @@ func (a *WrapperV1IMultiSig) MsigCancelTxnHash(ctx context.Context, msig address
}

func (a *WrapperV1IMultiSig) MsigAddPropose(ctx context.Context, msig address.Address, src address.Address, newAdd address.Address, inc bool) (cid.Cid, error) {

p, err := a.IMultiSig.MsigAddPropose(ctx, msig, src, newAdd, inc)
if err != nil {
return cid.Undef, fmt.Errorf("creating prototype: %w", err)
Expand All @@ -95,7 +93,6 @@ func (a *WrapperV1IMultiSig) MsigAddPropose(ctx context.Context, msig address.Ad
}

func (a *WrapperV1IMultiSig) MsigAddApprove(ctx context.Context, msig address.Address, src address.Address, txID uint64, proposer address.Address, newAdd address.Address, inc bool) (cid.Cid, error) {

p, err := a.IMultiSig.MsigAddApprove(ctx, msig, src, txID, proposer, newAdd, inc)
if err != nil {
return cid.Undef, fmt.Errorf("creating prototype: %w", err)
Expand All @@ -105,7 +102,6 @@ func (a *WrapperV1IMultiSig) MsigAddApprove(ctx context.Context, msig address.Ad
}

func (a *WrapperV1IMultiSig) MsigAddCancel(ctx context.Context, msig address.Address, src address.Address, txID uint64, newAdd address.Address, inc bool) (cid.Cid, error) {

p, err := a.IMultiSig.MsigAddCancel(ctx, msig, src, txID, newAdd, inc)
if err != nil {
return cid.Undef, fmt.Errorf("creating prototype: %w", err)
Expand All @@ -115,7 +111,6 @@ func (a *WrapperV1IMultiSig) MsigAddCancel(ctx context.Context, msig address.Add
}

func (a *WrapperV1IMultiSig) MsigSwapPropose(ctx context.Context, msig address.Address, src address.Address, oldAdd address.Address, newAdd address.Address) (cid.Cid, error) {

p, err := a.IMultiSig.MsigSwapPropose(ctx, msig, src, oldAdd, newAdd)
if err != nil {
return cid.Undef, fmt.Errorf("creating prototype: %w", err)
Expand All @@ -125,7 +120,6 @@ func (a *WrapperV1IMultiSig) MsigSwapPropose(ctx context.Context, msig address.A
}

func (a *WrapperV1IMultiSig) MsigSwapApprove(ctx context.Context, msig address.Address, src address.Address, txID uint64, proposer address.Address, oldAdd address.Address, newAdd address.Address) (cid.Cid, error) {

p, err := a.IMultiSig.MsigSwapApprove(ctx, msig, src, txID, proposer, oldAdd, newAdd)
if err != nil {
return cid.Undef, fmt.Errorf("creating prototype: %w", err)
Expand All @@ -135,7 +129,6 @@ func (a *WrapperV1IMultiSig) MsigSwapApprove(ctx context.Context, msig address.A
}

func (a *WrapperV1IMultiSig) MsigSwapCancel(ctx context.Context, msig address.Address, src address.Address, txID uint64, oldAdd address.Address, newAdd address.Address) (cid.Cid, error) {

p, err := a.IMultiSig.MsigSwapCancel(ctx, msig, src, txID, oldAdd, newAdd)
if err != nil {
return cid.Undef, fmt.Errorf("creating prototype: %w", err)
Expand All @@ -145,7 +138,6 @@ func (a *WrapperV1IMultiSig) MsigSwapCancel(ctx context.Context, msig address.Ad
}

func (a *WrapperV1IMultiSig) MsigRemoveSigner(ctx context.Context, msig address.Address, proposer address.Address, toRemove address.Address, decrease bool) (cid.Cid, error) {

p, err := a.IMultiSig.MsigRemoveSigner(ctx, msig, proposer, toRemove, decrease)
if err != nil {
return cid.Undef, fmt.Errorf("creating prototype: %w", err)
Expand Down
4 changes: 1 addition & 3 deletions app/submodule/network/libp2p.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func NewNoopLibP2PHost() noopLibP2PHost {
pid, _ := peer.IDFromPrivateKey(pk)
return noopLibP2PHost{pid}
}

func (h noopLibP2PHost) ID() peer.ID {
return h.peerId
}
Expand Down Expand Up @@ -57,11 +58,9 @@ func (noopLibP2PHost) Connect(ctx context.Context, pi peer.AddrInfo) error {
}

func (noopLibP2PHost) SetStreamHandler(pid protocol.ID, handler net.StreamHandler) {

}

func (noopLibP2PHost) SetStreamHandlerMatch(protocol.ID, func(string) bool, net.StreamHandler) {

}

func (noopLibP2PHost) RemoveStreamHandler(pid protocol.ID) {
Expand Down Expand Up @@ -119,7 +118,6 @@ func (noopLibP2PNetwork) ConnsToPeer(p peer.ID) []net.Conn {
}

func (noopLibP2PNetwork) Notify(net.Notifiee) {

}

func (noopLibP2PNetwork) StopNotify(net.Notifiee) {
Expand Down
Loading

0 comments on commit 5eb8361

Please sign in to comment.