Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: reformat all code with gofumpt #226

Merged
merged 3 commits into from
Oct 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions api/clients/mix_msgclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func NewMixMsgClient(params MPoolReplaceParams) IMixMessage {
nonceAssign: newNonceAssign(params.FullNode),
}
}

func (msgClient *MixMsgClient) PushMessage(ctx context.Context, p1 *types.Message, p2 *types.MessageSendSpec) (cid.Cid, error) {
if msgClient.messager == nil {
var sendSpec *types.MessageSendSpec
Expand All @@ -63,7 +64,7 @@ func (msgClient *MixMsgClient) PushMessage(ctx context.Context, p1 *types.Messag
if err != nil {
return cid.Undef, err
}
//estiamte -> sign -> push
// estimate -> sign -> push
estimatedMsg, err := msgClient.full.GasEstimateMessageGas(ctx, p1, sendSpec, types.EmptyTSK)
if err != nil {
return cid.Undef, err
Expand Down Expand Up @@ -111,7 +112,7 @@ func (msgClient *MixMsgClient) PushMessage(ctx context.Context, p1 *types.Messag
return cid.Undef, err
}
} else {
//for client account has in token
// for client account has in token
_, err = msgClient.messager.PushMessageWithId(ctx, msgid.String(), p1, nil)
if err != nil {
return cid.Undef, err
Expand Down Expand Up @@ -143,14 +144,14 @@ func (msgClient *MixMsgClient) WaitMsg(ctx context.Context, mCid cid.Cid, confid
}

switch msg.State {
//OffChain
// OffChain
case types2.FillMsg:
fallthrough
case types2.UnFillMsg:
fallthrough
case types2.UnKnown:
continue
//OnChain
// OnChain
case types2.ReplacedMsg:
fallthrough
case types2.OnChainMsg:
Expand All @@ -167,7 +168,7 @@ func (msgClient *MixMsgClient) WaitMsg(ctx context.Context, mCid cid.Cid, confid
}, nil
}
continue
//Error
// Error
case types2.FailedMsg:
var reason string
if msg.Receipt != nil {
Expand Down Expand Up @@ -196,14 +197,14 @@ func (msgClient *MixMsgClient) SearchMsg(ctx context.Context, from types.TipSetK
}

switch msg.State {
//OffChain
// OffChain
case types2.FillMsg:
fallthrough
case types2.UnFillMsg:
fallthrough
case types2.UnKnown:
return nil, nil
//OnChain
// OnChain
case types2.ReplacedMsg:
fallthrough
case types2.OnChainMsg:
Expand All @@ -217,7 +218,7 @@ func (msgClient *MixMsgClient) SearchMsg(ctx context.Context, from types.TipSetK
TipSet: msg.TipSetKey,
Height: abi.ChainEpoch(msg.Height),
}, nil
//Error
// Error
case types2.FailedMsg:
var reason string
if msg.Receipt != nil {
Expand Down
4 changes: 1 addition & 3 deletions api/clients/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ import (

var log = logging.Logger("clients")

var (
ReplaceWalletMethod = builder.NextInvoke()
)
var ReplaceWalletMethod = builder.NextInvoke()

func ConvertWalletToISinge(fullNode v1api.FullNode, signer ISinger) error {
fullNodeStruct := fullNode.(*v1api.FullNodeStruct)
Expand Down
6 changes: 3 additions & 3 deletions api/clients/nonce_assign.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ func newNonceAssign(full v1api.FullNode) *nonceAssigner {
return &nonceAssigner{full: full, lk: sync.Mutex{}}
}

//AssignNonce assign next nonce for address, in solo mode, should use a separate address for market message, should save nonce
//when only connect one daemon, MpoolGetNonce works well, but may have conflict nonce if use multiple daemon behind proxy
//todo save assgined nonce in local database
// AssignNonce assign next nonce for address, in solo mode, should use a separate address for market message, should save nonce
// when only connect one daemon, MpoolGetNonce works well, but may have conflict nonce if use multiple daemon behind proxy
// todo save assgined nonce in local database
func (nonceAssign *nonceAssigner) AssignNonce(ctx context.Context, addr address.Address) (uint64, error) {
nonceAssign.lk.Lock()
defer nonceAssign.lk.Unlock()
Expand Down
4 changes: 2 additions & 2 deletions api/impl/market_clent.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type MarketClientNodeImpl struct {
}

func (m *MarketClientNodeImpl) MessagerWaitMessage(ctx context.Context, mid cid.Cid) (*vTypes.MsgLookup, error) {
//WaitMsg method has been replace in messager mode
// WaitMsg method has been replace in messager mode
return m.Messager.WaitMsg(ctx, mid, constants.MessageConfidence, constants.LookbackNoLimit, false)
}

Expand All @@ -38,7 +38,7 @@ func (m *MarketClientNodeImpl) MessagerPushMessage(ctx context.Context, msg *vTy
}

func (m *MarketClientNodeImpl) MessagerGetMessage(ctx context.Context, mid cid.Cid) (*vTypes.Message, error) {
//ChainGetMessage method has been replace in messager mode
// ChainGetMessage method has been replace in messager mode
return m.Messager.GetMessage(ctx, mid)
}

Expand Down
22 changes: 13 additions & 9 deletions api/impl/venus_market.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ import (
types "github.com/filecoin-project/venus/venus-shared/types/market"
)

var _ marketapi.IMarket = (*MarketNodeImpl)(nil)
var log = logging.Logger("market_api")
var (
_ marketapi.IMarket = (*MarketNodeImpl)(nil)
log = logging.Logger("market_api")
)

type MarketNodeImpl struct {
FundAPI
Expand Down Expand Up @@ -389,7 +391,7 @@ func (m *MarketNodeImpl) SectorSetExpectedSealDuration(ctx context.Context, dura
}

func (m *MarketNodeImpl) MessagerWaitMessage(ctx context.Context, mid cid.Cid) (*vTypes.MsgLookup, error) {
//WaitMsg method has been replace in messager mode
// WaitMsg method has been replace in messager mode
return m.Messager.WaitMsg(ctx, mid, constants.MessageConfidence, constants.LookbackNoLimit, false)
}

Expand Down Expand Up @@ -476,7 +478,7 @@ func (m *MarketNodeImpl) DagstoreListShards(ctx context.Context) ([]types.Dagsto
}

func (m *MarketNodeImpl) DagstoreInitializeShard(ctx context.Context, key string) error {
//check whether key valid
// check whether key valid
cidKey, err := cid.Decode(key)
if err != nil {
return err
Expand All @@ -486,7 +488,7 @@ func (m *MarketNodeImpl) DagstoreInitializeShard(ctx context.Context, key string
return err
}

//check whether shard info exit
// check whether shard info exit
k := shard.KeyFromString(key)
info, err := m.DAGStore.GetShardInfo(k)
if err != nil && err != dagstore.ErrShardUnknown {
Expand Down Expand Up @@ -529,12 +531,12 @@ func (m *MarketNodeImpl) DagstoreInitializeAll(ctx context.Context, params types
if onlyUnsealed {
_, err = m.PieceStorageMgr.FindStorageForRead(ctx, pieceCid.String())
if err != nil {
//todo unseal
// todo unseal
log.Warnw("DagstoreInitializeAll: failed to get unsealed status; skipping deal", "piece cid", pieceCid, "error", err)
continue
}
}
//todo trigger unseal
// todo trigger unseal
// yes, we're initializing this shard.
toInitialize = append(toInitialize, pieceCid.String())
}
Expand Down Expand Up @@ -661,6 +663,7 @@ func (m *MarketNodeImpl) dagstoreLoadShards(ctx context.Context, toInitialize []

return res, nil
}

func (m *MarketNodeImpl) DagstoreRecoverShard(ctx context.Context, key string) error {
k := shard.KeyFromString(key)

Expand Down Expand Up @@ -836,7 +839,7 @@ func (m *MarketNodeImpl) ImportV1Data(ctx context.Context, src string) error {
err = m.Repo.RetrievalDealRepo().SaveDeal(ctx, &types.ProviderDealState{
DealProposal: retrievalDeal.DealProposal,
StoreID: retrievalDeal.StoreID,
//SelStorageProposalCid: retrievalDeal,
// SelStorageProposalCid: retrievalDeal,
ChannelID: retrievalDeal.ChannelID,
Status: retrievalDeal.Status,
Receiver: retrievalDeal.Receiver,
Expand Down Expand Up @@ -879,7 +882,8 @@ func (m *MarketNodeImpl) AddS3PieceStorage(ctx context.Context, name, endpoit, b
SubDir: subdir,
AccessKey: accessKeyID,
SecretKey: secretAccessKey,
Token: token}
Token: token,
}
s3ps, err := piecestorage.NewS3PieceStorage(ifs)
if err != nil {
return err
Expand Down
20 changes: 10 additions & 10 deletions blockstore/badger/blockstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ import (
"github.com/filecoin-project/venus-market/v2/blockstore"
)

var (
// KeyPool is the buffer pool we use to compute piecestorage keys.
KeyPool *pool.BufferPool = pool.GlobalPool
)
// KeyPool is the buffer pool we use to compute piecestorage keys.
var KeyPool *pool.BufferPool = pool.GlobalPool

var (
// ErrBlockstoreClosed is returned from blockstore operations after
Expand Down Expand Up @@ -122,12 +120,14 @@ type Blockstore struct {
prefixLen int
}

var _ blockstore.Blockstore = (*Blockstore)(nil)
var _ blockstore.Viewer = (*Blockstore)(nil)
var _ blockstore.BlockstoreIterator = (*Blockstore)(nil)
var _ blockstore.BlockstoreGC = (*Blockstore)(nil)
var _ blockstore.BlockstoreSize = (*Blockstore)(nil)
var _ io.Closer = (*Blockstore)(nil)
var (
_ blockstore.Blockstore = (*Blockstore)(nil)
_ blockstore.Viewer = (*Blockstore)(nil)
_ blockstore.BlockstoreIterator = (*Blockstore)(nil)
_ blockstore.BlockstoreGC = (*Blockstore)(nil)
_ blockstore.BlockstoreSize = (*Blockstore)(nil)
_ io.Closer = (*Blockstore)(nil)
)

// Open creates a new badger-backed blockstore, with the supplied options.
func Open(opts Options) (*Blockstore, error) {
Expand Down
1 change: 0 additions & 1 deletion blockstore/badger/blockstore_test_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ func (s *Suite) TestDelete(t *testing.T) {
has, err := bs.Has(ctx, blks[1].Cid())
require.NoError(t, err)
require.False(t, has)

}

func insertBlocks(t *testing.T, bs blockstore.BasicBlockstore, count int) []cid.Cid {
Expand Down
4 changes: 1 addition & 3 deletions blockstore/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ import (
// OpenCensus.
var CacheMetricsEmitInterval = 5 * time.Second

var (
CacheName, _ = tag.NewKey("cache_name")
)
var CacheName, _ = tag.NewKey("cache_name")

// CacheMeasures groups all metrics emitted by the blockstore caches.
var CacheMeasures = struct {
Expand Down
2 changes: 0 additions & 2 deletions cli/actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ var actorSetAddrsCmd = &cli.Command{

fmt.Printf("Requested multiaddrs change in message %s\n", mid)
return nil

},
}

Expand Down Expand Up @@ -227,7 +226,6 @@ var actorSetPeeridCmd = &cli.Command{

fmt.Printf("Requested peerid change in message %s\n", mid)
return nil

},
}

Expand Down
3 changes: 1 addition & 2 deletions cli/market.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ var dealsImportDataCmd = &cli.Command{
fpath := cctx.Args().Get(1)

return api.DealsImportData(ctx, propCid, fpath)

},
}

Expand Down Expand Up @@ -455,7 +454,7 @@ var dealsListCmd = &cli.Command{
return err
}
defer closer()
var maddr = address.Undef
maddr := address.Undef
if cctx.IsSet("miner") {
maddr, err = address.NewFromString(cctx.String("miner"))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cli/market_funds.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var MarketCmds = &cli.Command{
walletMarketWithdraw,
},
}

var marketBalancesCmd = &cli.Command{
Name: "balances",
Usage: "Print storage market client balances",
Expand Down Expand Up @@ -145,7 +146,6 @@ var walletMarketAdd = &cli.Command{
Method: market.Methods.AddBalance,
Params: params,
}, nil)

if err != nil {
return err
}
Expand Down
1 change: 0 additions & 1 deletion cli/piece-storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ var pieceStorageListCmd = &cli.Command{
)

for _, storage := range storagelist.FsStorage {

w.Write(map[string]interface{}{
"Name": storage.Name,
"Readonly": storage.ReadOnly,
Expand Down
1 change: 0 additions & 1 deletion cli/retrieval-deals.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,5 @@ var retrievalGetAskCmd = &cli.Command{
units.BytesSize(float64(ask.PaymentIntervalIncrease)),
)
return w.Flush()

},
}
5 changes: 2 additions & 3 deletions cli/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ var StatsPowerCmd = &cli.Command{
default:
}
err := func() error {

log.Println("Checking SP: ", maddr)

minfo, err := api.StateMinerInfo(ctx, maddr, types.EmptyTSK)
Expand Down Expand Up @@ -198,8 +197,8 @@ var StatsDealskCmd = &cli.Command{
return err
}

var totalDealSize = big.Zero()
var count = 0
totalDealSize := big.Zero()
count := 0

for _, deal := range deals {
state := deal.State
Expand Down
2 changes: 1 addition & 1 deletion cli/tablewriter/tablewriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func NewLineCol(name string) Column {
}

// Unlike text/tabwriter, this works with CLI escape codes, and allows for info
// in separate lines
// in separate lines
func New(cols ...Column) *TableWriter {
return &TableWriter{
cols: cols,
Expand Down
Loading