Skip to content

Commit 04603ac

Browse files
Go fmt
1 parent 5f59ca7 commit 04603ac

61 files changed

Lines changed: 159 additions & 144 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

bcs/consensus/pow/common.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ import (
88
)
99

1010
// PoWConfig pow需要解析的创始块解析格式
11-
// 根据Bitcoin推荐
12-
// AdjustHeightGap: 2016,
13-
// MaxTarget: 0x1d00FFFF,
14-
// DefaultTarget: 0x207FFFFF
11+
//
12+
// 根据Bitcoin推荐
13+
// AdjustHeightGap: 2016,
14+
// MaxTarget: 0x1d00FFFF,
15+
// DefaultTarget: 0x207FFFFF
1516
type PoWConfig struct {
1617
DefaultTarget uint32 `json:"defaultTarget"`
1718
AdjustHeightGap int32 `json:"adjustHeightGap"`

bcs/consensus/pow/pow.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ func (pow *PoWConsensus) ProcessBeforeMiner(height, timestamp int64) ([]byte, []
246246
bits, err := pow.refreshDifficulty(preBlock.GetBlockid(), tipHeight+1)
247247
if err != nil {
248248
// TODO: deal with error
249-
_ = pow.Stop()
249+
_ = pow.Stop()
250250
}
251251
pow.targetBits = bits
252252
store := &PoWStorage{
@@ -393,7 +393,7 @@ func (pow *PoWConsensus) refreshDifficulty(tipHash []byte, nextHeight int64) (ui
393393
return newTargetBits, nil
394394
}
395395

396-
//IsProofed check workload proof
396+
// IsProofed check workload proof
397397
func (pow *PoWConsensus) IsProofed(blockID []byte, targetBits uint32) bool {
398398
hash := new(big.Int)
399399
hash.SetBytes(blockID)

bcs/consensus/tdpos/kernel_contract.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ func (tp *tdposConsensus) runRevokeCandidate(contractCtx contract.KContext) (*co
180180

181181
// runVote 执行投票
182182
// Args: candidate::候选人钱包地址
183-
// amount::投票者票数
183+
//
184+
// amount::投票者票数
184185
func (tp *tdposConsensus) runVote(contractCtx contract.KContext) (*contract.Response, error) {
185186
// 1.1 验证合约参数是否正确
186187
candidateName, err := tp.checkArgs(contractCtx.Args())
@@ -253,7 +254,8 @@ func (tp *tdposConsensus) runVote(contractCtx contract.KContext) (*contract.Resp
253254
// runRevokeVote 执行选票撤销
254255
// 重构后的候选人撤销
255256
// Args: candidate::候选人钱包地址
256-
// amount: 投票数
257+
//
258+
// amount: 投票数
257259
func (tp *tdposConsensus) runRevokeVote(contractCtx contract.KContext) (*contract.Response, error) {
258260
// 1.1 验证合约参数
259261
candidateName, err := tp.checkArgs(contractCtx.Args())

bcs/consensus/tdpos/tdpos_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"testing"
66
"time"
77

8-
"github.com/golang/protobuf/proto" //nolint:staticcheck
8+
"github.com/golang/protobuf/proto" //nolint:staticcheck
99

1010
bmock "github.com/xuperchain/xupercore/bcs/consensus/mock"
1111
lpb "github.com/xuperchain/xupercore/bcs/ledger/xledger/xldgpb"

bcs/consensus/xpoa/xpoa_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"testing"
66
"time"
77

8-
"github.com/golang/protobuf/proto" //nolint:staticcheck
8+
"github.com/golang/protobuf/proto" //nolint:staticcheck
99
bmock "github.com/xuperchain/xupercore/bcs/consensus/mock"
1010
lpb "github.com/xuperchain/xupercore/bcs/ledger/xledger/xldgpb"
1111
cctx "github.com/xuperchain/xupercore/kernel/consensus/context"

bcs/ledger/xledger/ledger/ledger.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"sync"
1414
"time"
1515

16-
"github.com/golang/protobuf/proto" //nolint:staticcheck
16+
"github.com/golang/protobuf/proto" //nolint:staticcheck
1717

1818
"github.com/xuperchain/xupercore/bcs/ledger/xledger/def"
1919
pb "github.com/xuperchain/xupercore/bcs/ledger/xledger/xldgpb"
@@ -353,7 +353,7 @@ func (l *Ledger) formatBlock(txList []*pb.Transaction,
353353
return block, nil
354354
}
355355

356-
//保存一个区块(只包括区块头)
356+
// 保存一个区块(只包括区块头)
357357
// 注:只是打包到一个leveldb batch write对象中
358358
func (l *Ledger) saveBlock(block *pb.InternalBlock, batchWrite kvdb.Batch) error {
359359
header := *block
@@ -385,7 +385,7 @@ func (l *Ledger) fetchBlockForModify(blockid []byte) (*pb.InternalBlock, error)
385385
return &blk, nil
386386
}
387387

388-
//根据blockid获取一个Block, 只包含区块头
388+
// 根据blockid获取一个Block, 只包含区块头
389389
func (l *Ledger) fetchBlock(blockid []byte) (*pb.InternalBlock, error) {
390390
blkInCache, cacheHit := l.blkHeaderCache.Get(string(blockid))
391391
if cacheHit {
@@ -409,7 +409,7 @@ func (l *Ledger) fetchBlock(blockid []byte) (*pb.InternalBlock, error) {
409409
return block, nil
410410
}
411411

412-
//当发生主干切换后,确保最长路径上的block的tx的blockid指向它
412+
// 当发生主干切换后,确保最长路径上的block的tx的blockid指向它
413413
func (l *Ledger) correctTxsBlockid(blockID []byte, batchWrite kvdb.Batch) error {
414414
block, err := l.queryBlock(blockID, true)
415415
if err != nil {
@@ -432,10 +432,12 @@ func (l *Ledger) correctTxsBlockid(blockID []byte, batchWrite kvdb.Batch) error
432432
return nil
433433
}
434434

435-
//处理分叉
435+
// 处理分叉
436436
// P---->P---->P---->P (old tip)
437-
// |
438-
// +---->Q---->Q--->NewTip
437+
//
438+
// |
439+
// +---->Q---->Q--->NewTip
440+
//
439441
// 处理完后,会返回分叉点的block
440442
func (l *Ledger) handleFork(oldTip []byte, newTipPre []byte, nextHash []byte, batchWrite kvdb.Batch) (*pb.InternalBlock, error) {
441443
p := oldTip

bcs/ledger/xledger/ledger/ledger_hash.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func MakeMerkleTree(txList []*pb.Transaction) [][]byte {
144144
// wg.Wait()
145145
// }
146146

147-
//序列化系统合约失败的Txs
147+
// 序列化系统合约失败的Txs
148148
func encodeFailedTxs(buf *bytes.Buffer, block *pb.InternalBlock) error {
149149
txids := []string{}
150150
for txid := range block.FailedTxs {

bcs/ledger/xledger/ledger/ledger_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
//"os"
1414
"testing"
1515

16-
"github.com/golang/protobuf/proto" //nolint:staticcheck
16+
"github.com/golang/protobuf/proto" //nolint:staticcheck
1717

1818
"github.com/xuperchain/xupercore/bcs/ledger/xledger/state/utxo/txhash"
1919
pb "github.com/xuperchain/xupercore/bcs/ledger/xledger/xldgpb"

bcs/ledger/xledger/state/context/context.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func (t *StateCtx) SetTimerTaskMG(timerTaskMgr timerTask.TimerManager) {
9595
t.TimerTaskMgr = timerTaskMgr
9696
}
9797

98-
//state各个func里尽量调一下判断
98+
// state各个func里尽量调一下判断
9999
func (t *StateCtx) IsInit() bool {
100100
if t.AclMgr == nil || t.ContractMgr == nil || t.GovernTokenMgr == nil || t.ProposalMgr == nil ||
101101
t.TimerTaskMgr == nil || t.Crypt == nil || t.Ledger == nil {

bcs/ledger/xledger/state/meta/meta.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import (
55
"fmt"
66
"sync"
77

8-
"github.com/golang/protobuf/proto" //nolint:staticcheck
8+
"github.com/golang/protobuf/proto" //nolint:staticcheck
99

10-
rich "github.com/xuperchain/xupercore/bcs/ledger/xledger/batch"
10+
rb "github.com/xuperchain/xupercore/bcs/ledger/xledger/batch"
1111
"github.com/xuperchain/xupercore/bcs/ledger/xledger/def"
1212
"github.com/xuperchain/xupercore/bcs/ledger/xledger/ledger"
1313
"github.com/xuperchain/xupercore/bcs/ledger/xledger/state/context"
@@ -133,7 +133,7 @@ func (t *Meta) UpdateNewAccountResourceAmount(newAccountResourceAmount int64, ba
133133
t.log.Warn("failed to marshal pb meta")
134134
return pbErr
135135
}
136-
err := rich.NewRichBatch(batch).PutMeta(ledger.NewAccountResourceAmountKey, newAccountResourceAmountBuf)
136+
err := rb.NewRichBatch(batch).PutMeta(ledger.NewAccountResourceAmountKey, newAccountResourceAmountBuf)
137137
if err == nil {
138138
t.log.Info("Update newAccountResourceAmount succeed")
139139
}
@@ -185,7 +185,7 @@ func (t *Meta) UpdateMaxBlockSize(maxBlockSize int64, batch kvdb.Batch) error {
185185
t.log.Warn("failed to marshal pb meta")
186186
return pbErr
187187
}
188-
err := rich.NewRichBatch(batch).PutMeta(ledger.MaxBlockSizeKey, maxBlockSizeBuf)
188+
err := rb.NewRichBatch(batch).PutMeta(ledger.MaxBlockSizeKey, maxBlockSizeBuf)
189189
if err == nil {
190190
t.log.Info("Update maxBlockSize succeed")
191191
}
@@ -213,7 +213,7 @@ func (t *Meta) LoadReservedContracts() ([]*protos.InvokeRequest, error) {
213213
return nil, findErr
214214
}
215215

216-
//when to register to kernel method
216+
// when to register to kernel method
217217
func (t *Meta) UpdateReservedContracts(params []*protos.InvokeRequest, batch kvdb.Batch) error {
218218
if params == nil {
219219
return fmt.Errorf("invalid reservered contract requests")
@@ -226,7 +226,7 @@ func (t *Meta) UpdateReservedContracts(params []*protos.InvokeRequest, batch kvd
226226
t.log.Warn("failed to marshal pb meta")
227227
return pbErr
228228
}
229-
err := rich.NewRichBatch(batch).PutMeta(ledger.ReservedContractsKey, paramsBuf)
229+
err := rb.NewRichBatch(batch).PutMeta(ledger.ReservedContractsKey, paramsBuf)
230230
if err == nil {
231231
t.log.Info("Update reservered contract succeed")
232232
}
@@ -292,7 +292,7 @@ func (t *Meta) UpdateForbiddenContract(param *protos.InvokeRequest, batch kvdb.B
292292
t.log.Warn("failed to marshal pb meta")
293293
return pbErr
294294
}
295-
err := rich.NewRichBatch(batch).PutMeta(ledger.ForbiddenContractKey, paramBuf)
295+
err := rb.NewRichBatch(batch).PutMeta(ledger.ForbiddenContractKey, paramBuf)
296296
if err == nil {
297297
t.log.Info("Update forbidden contract succeed")
298298
}
@@ -352,7 +352,7 @@ func (t *Meta) UpdateIrreversibleBlockHeight(nextIrreversibleBlockHeight int64,
352352
t.log.Warn("failed to marshal pb meta")
353353
return pbErr
354354
}
355-
err := rich.NewRichBatch(batch).PutMeta(ledger.IrreversibleBlockHeightKey, irreversibleBlockHeightBuf)
355+
err := rb.NewRichBatch(batch).PutMeta(ledger.IrreversibleBlockHeightKey, irreversibleBlockHeightBuf)
356356
if err != nil {
357357
return err
358358
}
@@ -427,7 +427,7 @@ func (t *Meta) UpdateIrreversibleSlideWindow(nextIrreversibleSlideWindow int64,
427427
t.log.Warn("failed to marshal pb meta")
428428
return pbErr
429429
}
430-
err := rich.NewRichBatch(batch).PutMeta(ledger.IrreversibleSlideWindowKey, irreversibleSlideWindowBuf)
430+
err := rb.NewRichBatch(batch).PutMeta(ledger.IrreversibleSlideWindowKey, irreversibleSlideWindowBuf)
431431
if err != nil {
432432
return err
433433
}
@@ -506,7 +506,7 @@ func (t *Meta) UpdateGasPrice(nextGasPrice *protos.GasPrice, batch kvdb.Batch) e
506506
t.log.Warn("failed to marshal pb meta")
507507
return pbErr
508508
}
509-
err := rich.NewRichBatch(batch).PutMeta(ledger.GasPriceKey, gasPriceBuf)
509+
err := rb.NewRichBatch(batch).PutMeta(ledger.GasPriceKey, gasPriceBuf)
510510
if err != nil {
511511
return err
512512
}

0 commit comments

Comments
 (0)