diff --git a/bcs/consensus/pow/common.go b/bcs/consensus/pow/common.go index 61d3d7dd..d2b00c5f 100644 --- a/bcs/consensus/pow/common.go +++ b/bcs/consensus/pow/common.go @@ -8,10 +8,11 @@ import ( ) // PoWConfig pow需要解析的创始块解析格式 -// 根据Bitcoin推荐 -// AdjustHeightGap: 2016, -// MaxTarget: 0x1d00FFFF, -// DefaultTarget: 0x207FFFFF +// +// 根据Bitcoin推荐 +// AdjustHeightGap: 2016, +// MaxTarget: 0x1d00FFFF, +// DefaultTarget: 0x207FFFFF type PoWConfig struct { DefaultTarget uint32 `json:"defaultTarget"` AdjustHeightGap int32 `json:"adjustHeightGap"` diff --git a/bcs/consensus/pow/pow.go b/bcs/consensus/pow/pow.go index 9893302b..6594a772 100644 --- a/bcs/consensus/pow/pow.go +++ b/bcs/consensus/pow/pow.go @@ -246,7 +246,7 @@ func (pow *PoWConsensus) ProcessBeforeMiner(height, timestamp int64) ([]byte, [] bits, err := pow.refreshDifficulty(preBlock.GetBlockid(), tipHeight+1) if err != nil { // TODO: deal with error - _ = pow.Stop() + _ = pow.Stop() } pow.targetBits = bits store := &PoWStorage{ @@ -393,7 +393,7 @@ func (pow *PoWConsensus) refreshDifficulty(tipHash []byte, nextHeight int64) (ui return newTargetBits, nil } -//IsProofed check workload proof +// IsProofed check workload proof func (pow *PoWConsensus) IsProofed(blockID []byte, targetBits uint32) bool { hash := new(big.Int) hash.SetBytes(blockID) diff --git a/bcs/consensus/tdpos/kernel_contract.go b/bcs/consensus/tdpos/kernel_contract.go index 57fc3542..bd62a834 100644 --- a/bcs/consensus/tdpos/kernel_contract.go +++ b/bcs/consensus/tdpos/kernel_contract.go @@ -180,7 +180,8 @@ func (tp *tdposConsensus) runRevokeCandidate(contractCtx contract.KContext) (*co // runVote 执行投票 // Args: candidate::候选人钱包地址 -// amount::投票者票数 +// +// amount::投票者票数 func (tp *tdposConsensus) runVote(contractCtx contract.KContext) (*contract.Response, error) { // 1.1 验证合约参数是否正确 candidateName, err := tp.checkArgs(contractCtx.Args()) @@ -253,7 +254,8 @@ func (tp *tdposConsensus) runVote(contractCtx contract.KContext) (*contract.Resp // runRevokeVote 执行选票撤销 // 重构后的候选人撤销 // Args: candidate::候选人钱包地址 -// amount: 投票数 +// +// amount: 投票数 func (tp *tdposConsensus) runRevokeVote(contractCtx contract.KContext) (*contract.Response, error) { // 1.1 验证合约参数 candidateName, err := tp.checkArgs(contractCtx.Args()) diff --git a/bcs/consensus/tdpos/tdpos_test.go b/bcs/consensus/tdpos/tdpos_test.go index 0cecc00c..7937d3d4 100644 --- a/bcs/consensus/tdpos/tdpos_test.go +++ b/bcs/consensus/tdpos/tdpos_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "github.com/golang/protobuf/proto" //nolint:staticcheck + "github.com/golang/protobuf/proto" //nolint:staticcheck bmock "github.com/xuperchain/xupercore/bcs/consensus/mock" lpb "github.com/xuperchain/xupercore/bcs/ledger/xledger/xldgpb" diff --git a/bcs/consensus/xpoa/xpoa_test.go b/bcs/consensus/xpoa/xpoa_test.go index 895f7eb0..1831cedd 100644 --- a/bcs/consensus/xpoa/xpoa_test.go +++ b/bcs/consensus/xpoa/xpoa_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "github.com/golang/protobuf/proto" //nolint:staticcheck + "github.com/golang/protobuf/proto" //nolint:staticcheck bmock "github.com/xuperchain/xupercore/bcs/consensus/mock" lpb "github.com/xuperchain/xupercore/bcs/ledger/xledger/xldgpb" cctx "github.com/xuperchain/xupercore/kernel/consensus/context" diff --git a/bcs/ledger/xledger/ledger/ledger.go b/bcs/ledger/xledger/ledger/ledger.go index f7ac6435..61788d13 100644 --- a/bcs/ledger/xledger/ledger/ledger.go +++ b/bcs/ledger/xledger/ledger/ledger.go @@ -13,7 +13,7 @@ import ( "sync" "time" - "github.com/golang/protobuf/proto" //nolint:staticcheck + "github.com/golang/protobuf/proto" //nolint:staticcheck "github.com/xuperchain/xupercore/bcs/ledger/xledger/def" pb "github.com/xuperchain/xupercore/bcs/ledger/xledger/xldgpb" @@ -353,7 +353,7 @@ func (l *Ledger) formatBlock(txList []*pb.Transaction, return block, nil } -//保存一个区块(只包括区块头) +// 保存一个区块(只包括区块头) // 注:只是打包到一个leveldb batch write对象中 func (l *Ledger) saveBlock(block *pb.InternalBlock, batchWrite kvdb.Batch) error { header := *block @@ -385,7 +385,7 @@ func (l *Ledger) fetchBlockForModify(blockid []byte) (*pb.InternalBlock, error) return &blk, nil } -//根据blockid获取一个Block, 只包含区块头 +// 根据blockid获取一个Block, 只包含区块头 func (l *Ledger) fetchBlock(blockid []byte) (*pb.InternalBlock, error) { blkInCache, cacheHit := l.blkHeaderCache.Get(string(blockid)) if cacheHit { @@ -409,7 +409,7 @@ func (l *Ledger) fetchBlock(blockid []byte) (*pb.InternalBlock, error) { return block, nil } -//当发生主干切换后,确保最长路径上的block的tx的blockid指向它 +// 当发生主干切换后,确保最长路径上的block的tx的blockid指向它 func (l *Ledger) correctTxsBlockid(blockID []byte, batchWrite kvdb.Batch) error { block, err := l.queryBlock(blockID, true) if err != nil { @@ -432,10 +432,12 @@ func (l *Ledger) correctTxsBlockid(blockID []byte, batchWrite kvdb.Batch) error return nil } -//处理分叉 +// 处理分叉 // P---->P---->P---->P (old tip) -// | -// +---->Q---->Q--->NewTip +// +// | +// +---->Q---->Q--->NewTip +// // 处理完后,会返回分叉点的block func (l *Ledger) handleFork(oldTip []byte, newTipPre []byte, nextHash []byte, batchWrite kvdb.Batch) (*pb.InternalBlock, error) { p := oldTip diff --git a/bcs/ledger/xledger/ledger/ledger_hash.go b/bcs/ledger/xledger/ledger/ledger_hash.go index 59d4c552..5f092a62 100644 --- a/bcs/ledger/xledger/ledger/ledger_hash.go +++ b/bcs/ledger/xledger/ledger/ledger_hash.go @@ -144,7 +144,7 @@ func MakeMerkleTree(txList []*pb.Transaction) [][]byte { // wg.Wait() // } -//序列化系统合约失败的Txs +// 序列化系统合约失败的Txs func encodeFailedTxs(buf *bytes.Buffer, block *pb.InternalBlock) error { txids := []string{} for txid := range block.FailedTxs { diff --git a/bcs/ledger/xledger/ledger/ledger_test.go b/bcs/ledger/xledger/ledger/ledger_test.go index 40c92ace..41e480c5 100644 --- a/bcs/ledger/xledger/ledger/ledger_test.go +++ b/bcs/ledger/xledger/ledger/ledger_test.go @@ -13,7 +13,7 @@ import ( //"os" "testing" - "github.com/golang/protobuf/proto" //nolint:staticcheck + "github.com/golang/protobuf/proto" //nolint:staticcheck "github.com/xuperchain/xupercore/bcs/ledger/xledger/state/utxo/txhash" pb "github.com/xuperchain/xupercore/bcs/ledger/xledger/xldgpb" diff --git a/bcs/ledger/xledger/state/context/context.go b/bcs/ledger/xledger/state/context/context.go index 2d441bed..d25c7a1a 100644 --- a/bcs/ledger/xledger/state/context/context.go +++ b/bcs/ledger/xledger/state/context/context.go @@ -95,7 +95,7 @@ func (t *StateCtx) SetTimerTaskMG(timerTaskMgr timerTask.TimerManager) { t.TimerTaskMgr = timerTaskMgr } -//state各个func里尽量调一下判断 +// state各个func里尽量调一下判断 func (t *StateCtx) IsInit() bool { if t.AclMgr == nil || t.ContractMgr == nil || t.GovernTokenMgr == nil || t.ProposalMgr == nil || t.TimerTaskMgr == nil || t.Crypt == nil || t.Ledger == nil { diff --git a/bcs/ledger/xledger/state/meta/meta.go b/bcs/ledger/xledger/state/meta/meta.go index 5f9d56cc..34248408 100644 --- a/bcs/ledger/xledger/state/meta/meta.go +++ b/bcs/ledger/xledger/state/meta/meta.go @@ -5,9 +5,9 @@ import ( "fmt" "sync" - "github.com/golang/protobuf/proto" //nolint:staticcheck + "github.com/golang/protobuf/proto" //nolint:staticcheck - rich "github.com/xuperchain/xupercore/bcs/ledger/xledger/batch" + rb "github.com/xuperchain/xupercore/bcs/ledger/xledger/batch" "github.com/xuperchain/xupercore/bcs/ledger/xledger/def" "github.com/xuperchain/xupercore/bcs/ledger/xledger/ledger" "github.com/xuperchain/xupercore/bcs/ledger/xledger/state/context" @@ -133,7 +133,7 @@ func (t *Meta) UpdateNewAccountResourceAmount(newAccountResourceAmount int64, ba t.log.Warn("failed to marshal pb meta") return pbErr } - err := rich.NewRichBatch(batch).PutMeta(ledger.NewAccountResourceAmountKey, newAccountResourceAmountBuf) + err := rb.NewRichBatch(batch).PutMeta(ledger.NewAccountResourceAmountKey, newAccountResourceAmountBuf) if err == nil { t.log.Info("Update newAccountResourceAmount succeed") } @@ -185,7 +185,7 @@ func (t *Meta) UpdateMaxBlockSize(maxBlockSize int64, batch kvdb.Batch) error { t.log.Warn("failed to marshal pb meta") return pbErr } - err := rich.NewRichBatch(batch).PutMeta(ledger.MaxBlockSizeKey, maxBlockSizeBuf) + err := rb.NewRichBatch(batch).PutMeta(ledger.MaxBlockSizeKey, maxBlockSizeBuf) if err == nil { t.log.Info("Update maxBlockSize succeed") } @@ -213,7 +213,7 @@ func (t *Meta) LoadReservedContracts() ([]*protos.InvokeRequest, error) { return nil, findErr } -//when to register to kernel method +// when to register to kernel method func (t *Meta) UpdateReservedContracts(params []*protos.InvokeRequest, batch kvdb.Batch) error { if params == nil { return fmt.Errorf("invalid reservered contract requests") @@ -226,7 +226,7 @@ func (t *Meta) UpdateReservedContracts(params []*protos.InvokeRequest, batch kvd t.log.Warn("failed to marshal pb meta") return pbErr } - err := rich.NewRichBatch(batch).PutMeta(ledger.ReservedContractsKey, paramsBuf) + err := rb.NewRichBatch(batch).PutMeta(ledger.ReservedContractsKey, paramsBuf) if err == nil { t.log.Info("Update reservered contract succeed") } @@ -292,7 +292,7 @@ func (t *Meta) UpdateForbiddenContract(param *protos.InvokeRequest, batch kvdb.B t.log.Warn("failed to marshal pb meta") return pbErr } - err := rich.NewRichBatch(batch).PutMeta(ledger.ForbiddenContractKey, paramBuf) + err := rb.NewRichBatch(batch).PutMeta(ledger.ForbiddenContractKey, paramBuf) if err == nil { t.log.Info("Update forbidden contract succeed") } @@ -352,7 +352,7 @@ func (t *Meta) UpdateIrreversibleBlockHeight(nextIrreversibleBlockHeight int64, t.log.Warn("failed to marshal pb meta") return pbErr } - err := rich.NewRichBatch(batch).PutMeta(ledger.IrreversibleBlockHeightKey, irreversibleBlockHeightBuf) + err := rb.NewRichBatch(batch).PutMeta(ledger.IrreversibleBlockHeightKey, irreversibleBlockHeightBuf) if err != nil { return err } @@ -427,7 +427,7 @@ func (t *Meta) UpdateIrreversibleSlideWindow(nextIrreversibleSlideWindow int64, t.log.Warn("failed to marshal pb meta") return pbErr } - err := rich.NewRichBatch(batch).PutMeta(ledger.IrreversibleSlideWindowKey, irreversibleSlideWindowBuf) + err := rb.NewRichBatch(batch).PutMeta(ledger.IrreversibleSlideWindowKey, irreversibleSlideWindowBuf) if err != nil { return err } @@ -506,7 +506,7 @@ func (t *Meta) UpdateGasPrice(nextGasPrice *protos.GasPrice, batch kvdb.Batch) e t.log.Warn("failed to marshal pb meta") return pbErr } - err := rich.NewRichBatch(batch).PutMeta(ledger.GasPriceKey, gasPriceBuf) + err := rb.NewRichBatch(batch).PutMeta(ledger.GasPriceKey, gasPriceBuf) if err != nil { return err } diff --git a/bcs/ledger/xledger/state/state.go b/bcs/ledger/xledger/state/state.go index f48d9650..ca283a76 100644 --- a/bcs/ledger/xledger/state/state.go +++ b/bcs/ledger/xledger/state/state.go @@ -11,9 +11,9 @@ import ( "strconv" "time" - "github.com/golang/protobuf/proto" //nolint:staticcheck + "github.com/golang/protobuf/proto" //nolint:staticcheck - rich "github.com/xuperchain/xupercore/bcs/ledger/xledger/batch" + rb "github.com/xuperchain/xupercore/bcs/ledger/xledger/batch" "github.com/xuperchain/xupercore/bcs/ledger/xledger/def" "github.com/xuperchain/xupercore/bcs/ledger/xledger/ledger" "github.com/xuperchain/xupercore/bcs/ledger/xledger/state/context" @@ -432,7 +432,7 @@ func (t *State) PlayForMiner(blockid []byte) error { return err } } else { - rich.NewRichBatch(batch).DeleteUnconfirmedTx([]byte(txid)) + rb.NewRichBatch(batch).DeleteUnconfirmedTx([]byte(txid)) } err = t.payFee(tx, batch, block) if err != nil { @@ -829,7 +829,7 @@ func (t *State) doTxSync(tx *pb.Transaction) error { return err } - rich.NewRichBatch(batch).PutUnconfirmedTx(tx.Txid, pbTxBuf) + rb.NewRichBatch(batch).PutUnconfirmedTx(tx.Txid, pbTxBuf) t.log.Debug("print tx size when DoTx", "tx_size", batch.ValueSize(), "txid", utils.F(tx.Txid)) beginTime = time.Now() writeErr := batch.Write() @@ -860,7 +860,7 @@ func (t *State) doTxInternal(tx *pb.Transaction, batch kvdb.Batch, cacheFiller * t.log.Warn("xmodel DoTx failed", "err", err) return ErrRWSetInvalid } - richBatch := rich.NewRichBatch(batch) + richBatch := rb.NewRichBatch(batch) for _, txInput := range tx.TxInputs { addr := txInput.FromAddr txid := txInput.RefTxid @@ -987,7 +987,7 @@ func (t *State) undoUnconfirmedTx(tx *pb.Transaction, if undoErr != nil { return undoErr } - rich.NewRichBatch(batch).DeleteUnconfirmedTx(tx.Txid) + rb.NewRichBatch(batch).DeleteUnconfirmedTx(tx.Txid) // 记录回滚交易,用于重放 if undoDone != nil { @@ -1012,7 +1012,7 @@ func (t *State) undoTxInternal(tx *pb.Transaction, batch kvdb.Batch) error { return ErrRWSetInvalid } - richBatch := rich.NewRichBatch(batch) + richBatch := rb.NewRichBatch(batch) for _, txInput := range tx.TxInputs { addr := txInput.FromAddr txid := txInput.RefTxid @@ -1141,7 +1141,7 @@ func (t *State) updateLatestBlockid(newBlockid []byte, batch kvdb.Batch, reason if err != nil { return err } - if err := rich.NewRichBatch(batch).PutMeta(utxo.LatestBlockKey, newBlockid); err != nil { + if err := rb.NewRichBatch(batch).PutMeta(utxo.LatestBlockKey, newBlockid); err != nil { return err } writeErr := batch.Write() @@ -1156,7 +1156,7 @@ func (t *State) updateLatestBlockid(newBlockid []byte, batch kvdb.Batch, reason } func (t *State) undoPayFee(tx *pb.Transaction, batch kvdb.Batch, block *pb.InternalBlock) error { - richBatch := rich.NewRichBatch(batch) + richBatch := rb.NewRichBatch(batch) for offset, txOutput := range tx.TxOutputs { addr := txOutput.ToAddr if !bytes.Equal(addr, []byte(FeePlaceholder)) { @@ -1269,7 +1269,7 @@ func (t *State) payFee(tx *pb.Transaction, batch kvdb.Batch, block *pb.InternalB if uErr != nil { return uErr } - rich.NewRichBatch(batch).PutUtxoWithPrefix(utxoKey, uItemBinary)// 插入本交易产生的utxo + rb.NewRichBatch(batch).PutUtxoWithPrefix(utxoKey, uItemBinary) // 插入本交易产生的utxo t.utxo.AddBalance(addr, uItem.Amount) t.utxo.UtxoCache.Insert(string(addr), utxoKey, uItem) t.log.Trace(" insert fee utxo key", "utxoKey", utxoKey, "amount", uItem.Amount.String()) @@ -1362,7 +1362,7 @@ func (t *State) processUnconfirmTxs(block *pb.InternalBlock, batch kvdb.Batch, n txid := string(tx.GetTxid()) if t.tx.Mempool.HasTx(txid) { - rich.NewRichBatch(batch).DeleteUnconfirmedTx([]byte(txid)) + rb.NewRichBatch(batch).DeleteUnconfirmedTx([]byte(txid)) t.log.Trace(" delete from unconfirmed", "txid", fmt.Sprintf("%x", tx.GetTxid())) unconfirmToConfirm[txid] = true } @@ -1379,7 +1379,7 @@ func (t *State) processUnconfirmTxs(block *pb.InternalBlock, batch kvdb.Batch, n if undoDone[string(undoTx.Txid)] { continue } - rich.NewRichBatch(batch).DeleteUnconfirmedTx(undoTx.Txid) // mempool 中删除后,db 的未确认交易中也要删除。 + rb.NewRichBatch(batch).DeleteUnconfirmedTx(undoTx.Txid) // mempool 中删除后,db 的未确认交易中也要删除。 undoErr := t.undoUnconfirmedTx(undoTx, batch, undoDone, nil) if undoErr != nil { t.log.Warn("fail to undo tx", "undoErr", undoErr) diff --git a/bcs/ledger/xledger/state/tx_verification.go b/bcs/ledger/xledger/state/tx_verification.go index 4b4ca02a..5b42b434 100644 --- a/bcs/ledger/xledger/state/tx_verification.go +++ b/bcs/ledger/xledger/state/tx_verification.go @@ -25,21 +25,21 @@ import ( "github.com/xuperchain/xupercore/lib/metrics" "github.com/xuperchain/xupercore/protos" - "github.com/golang/protobuf/proto" //nolint:staticcheck + "github.com/golang/protobuf/proto" //nolint:staticcheck ) // ImmediateVerifyTx verify tx Immediately // Transaction verification workflow: -// 1. verify transaction ID is the same with data hash -// 2. verify all signatures of initiator and auth requires -// 3. verify the utxo input, there are three kinds of input validation -// 1). PKI technology for transferring from address -// 2). Account ACL for transferring from account -// 3). Contract logic transferring from contract -// 4. verify the contract requests' permission -// 5. verify the permission of contract RWSet (WriteSet could including unauthorized data change) -// 6. run contract requests and verify if the RWSet result is the same with preExed RWSet (heavy -// operation, keep it at last) +// 1. verify transaction ID is the same with data hash +// 2. verify all signatures of initiator and auth requires +// 3. verify the utxo input, there are three kinds of input validation +// 1). PKI technology for transferring from address +// 2). Account ACL for transferring from account +// 3). Contract logic transferring from contract +// 4. verify the contract requests' permission +// 5. verify the permission of contract RWSet (WriteSet could including unauthorized data change) +// 6. run contract requests and verify if the RWSet result is the same with preExed RWSet (heavy +// operation, keep it at last) func (t *State) ImmediateVerifyTx(tx *pb.Transaction, isRootTx bool) (bool, error) { beginTime := time.Now() code := "InvalidTx" @@ -149,10 +149,10 @@ func (t *State) ImmediateVerifyTx(tx *pb.Transaction, isRootTx bool) (bool, erro // ImmediateVerifyTx verify auto tx Immediately // Transaction verification workflow: -// 0. 其实可以直接判断二者的txid,相同,则包括读写集在内的内容都相同 -// 1. verify transaction ID is the same with data hash -// 2. run contract requests and verify if the RWSet result is the same with preExed RWSet (heavy -// operation, keep it at last) +// 0. 其实可以直接判断二者的txid,相同,则包括读写集在内的内容都相同 +// 1. verify transaction ID is the same with data hash +// 2. run contract requests and verify if the RWSet result is the same with preExed RWSet (heavy +// operation, keep it at last) func (t *State) ImmediateVerifyAutoTx(blockHeight int64, tx *pb.Transaction, isRootTx bool) (bool, error) { // 获取该区块触发的定时交易 autoTx, genErr := t.GetTimerTx(blockHeight) @@ -332,6 +332,7 @@ func (t *State) verifyXuperSign(tx *pb.Transaction, digestHash []byte) (bool, ma } // verify utxo inputs, there are three kinds of input validation +// // 1). PKI technology for transferring from address // 2). Account ACL for transferring from account // 3). Contract logic transferring from contract diff --git a/bcs/ledger/xledger/state/utxo/merge_utxo.go b/bcs/ledger/xledger/state/utxo/merge_utxo.go index 5cc9fc4d..9001b9ec 100644 --- a/bcs/ledger/xledger/state/utxo/merge_utxo.go +++ b/bcs/ledger/xledger/state/utxo/merge_utxo.go @@ -7,7 +7,7 @@ import ( "math/big" "strconv" - "github.com/golang/protobuf/proto" //nolint:staticcheck + "github.com/golang/protobuf/proto" //nolint:staticcheck pb "github.com/xuperchain/xupercore/bcs/ledger/xledger/xldgpb" "github.com/xuperchain/xupercore/protos" diff --git a/bcs/ledger/xledger/state/utxo/spin_lock.go b/bcs/ledger/xledger/state/utxo/spin_lock.go index b1c49d10..ff5e5893 100644 --- a/bcs/ledger/xledger/state/utxo/spin_lock.go +++ b/bcs/ledger/xledger/state/utxo/spin_lock.go @@ -19,7 +19,7 @@ type refCounter struct { mu sync.Mutex } -//SpinLock is a collections of small locks on special keys +// SpinLock is a collections of small locks on special keys type SpinLock struct { m *sync.Map refCounter *refCounter @@ -63,7 +63,7 @@ func NewSpinLock() *SpinLock { return &SpinLock{m: &sync.Map{}, refCounter: &refCounter{ctMap: map[string]int{}}} } -//ExtractLockKeys extract lock items from a transaction +// ExtractLockKeys extract lock items from a transaction func (sp *SpinLock) ExtractLockKeys(tx *pb.Transaction) []*LockKey { keys := []*LockKey{} for _, input := range tx.TxInputs { @@ -106,13 +106,13 @@ func (sp *SpinLock) ExtractLockKeys(tx *pb.Transaction) []*LockKey { return keys[:lim] } -//IsLocked returns whether a key is locked +// IsLocked returns whether a key is locked func (sp *SpinLock) IsLocked(key string) bool { _, locked := sp.m.Load(key) return locked } -//TryLock try to lock some keys +// TryLock try to lock some keys func (sp *SpinLock) TryLock(lockKeys []*LockKey) ([]*LockKey, bool) { succLocked := []*LockKey{} for _, k := range lockKeys { @@ -133,7 +133,7 @@ func (sp *SpinLock) TryLock(lockKeys []*LockKey) ([]*LockKey, bool) { return succLocked, true } -//Unlock release the locks on some keys +// Unlock release the locks on some keys func (sp *SpinLock) Unlock(lockKeys []*LockKey) { N := len(lockKeys) for i := N - 1; i >= 0; i-- { diff --git a/bcs/ledger/xledger/state/utxo/topsort.go b/bcs/ledger/xledger/state/utxo/topsort.go index 8cd23e3d..326812f8 100644 --- a/bcs/ledger/xledger/state/utxo/topsort.go +++ b/bcs/ledger/xledger/state/utxo/topsort.go @@ -4,13 +4,14 @@ import ( pb "github.com/xuperchain/xupercore/bcs/ledger/xledger/xldgpb" ) -//交易依赖关系图 +// 交易依赖关系图 type TxGraph map[string][]string -//TopSortDFS 对依赖关系图进行拓扑排序 +// TopSortDFS 对依赖关系图进行拓扑排序 // 输入:依赖关系图,就是个map // 输出: order: 排序后的有序数组,依赖者排在前面,被依赖的排在后面 -// cyclic: 如果发现有环形依赖关系则输出这个数组 +// +// cyclic: 如果发现有环形依赖关系则输出这个数组 // // 实现参考: https://rosettacode.org/wiki/Topological_sort#Go // 在我们映射中,RefTx是边的源点 diff --git a/bcs/ledger/xledger/state/utxo/txhash/encode.go b/bcs/ledger/xledger/state/utxo/txhash/encode.go index 354585ff..c17ec5e7 100644 --- a/bcs/ledger/xledger/state/utxo/txhash/encode.go +++ b/bcs/ledger/xledger/state/utxo/txhash/encode.go @@ -40,7 +40,6 @@ func (e *encoder) EncodeString(s string) { _, _ = io.WriteString(e.w, s) } - // EncodeBytes // write error is ignored func (e *encoder) EncodeBytes(s []byte) { diff --git a/bcs/ledger/xledger/state/utxo/utxo.go b/bcs/ledger/xledger/state/utxo/utxo.go index c8492001..63463a30 100755 --- a/bcs/ledger/xledger/state/utxo/utxo.go +++ b/bcs/ledger/xledger/state/utxo/utxo.go @@ -11,13 +11,13 @@ import ( "encoding/hex" "errors" "fmt" - utils2 "github.com/xuperchain/xupercore/bcs/ledger/xledger/batch" "math/big" "strconv" "strings" "sync" "time" + rb "github.com/xuperchain/xupercore/bcs/ledger/xledger/batch" "github.com/xuperchain/xupercore/bcs/ledger/xledger/def" "github.com/xuperchain/xupercore/bcs/ledger/xledger/ledger" "github.com/xuperchain/xupercore/bcs/ledger/xledger/state/context" @@ -271,9 +271,10 @@ func (uv *UtxoVM) clearExpiredLocks() { } // NewUtxoVM 构建一个UtxoVM对象 -// @param ledger 账本对象 -// @param store path, utxo 数据的保存路径 -// @param xlog , 日志handler +// +// @param ledger 账本对象 +// @param store path, utxo 数据的保存路径 +// @param xlog , 日志handler func NewUtxo(sctx *context.StateCtx, metaHandle *meta.Meta, stateDB kvdb.Database) (*UtxoVM, error) { return MakeUtxo(sctx, metaHandle, UTXOCacheSize, UTXOLockExpiredSecond, stateDB) } @@ -327,7 +328,7 @@ func (uv *UtxoVM) UpdateUtxoTotal(delta *big.Int, batch kvdb.Batch, inc bool) { uv.utxoTotal = uv.utxoTotal.Sub(uv.utxoTotal, delta) } // TODO: deal with error - _ = utils2.NewRichBatch(batch).PutMeta(UTXOTotalKey, uv.utxoTotal.Bytes()) + _ = rb.NewRichBatch(batch).PutMeta(UTXOTotalKey, uv.utxoTotal.Bytes()) } // parseUtxoKeys extract (txid, offset) from key of utxo item @@ -354,9 +355,9 @@ func (uv *UtxoVM) SelectUtxo(fromAddr string, totalNeed *big.Int, needLock, excl return uv.SelectUtxos(fromAddr, totalNeed, needLock, excludeUnconfirmed) } -//SelectUtxos 选择足够的utxo -//输入: 转账人地址、公钥、金额、是否需要锁定utxo -//输出:选出的utxo、utxo keys、实际构成的金额(可能大于需要的金额)、错误码 +// SelectUtxos 选择足够的utxo +// 输入: 转账人地址、公钥、金额、是否需要锁定utxo +// 输出:选出的utxo、utxo keys、实际构成的金额(可能大于需要的金额)、错误码 func (uv *UtxoVM) SelectUtxos(fromAddr string, totalNeed *big.Int, needLock, excludeUnconfirmed bool) ([]*protos.TxInput, [][]byte, *big.Int, error) { if totalNeed.Cmp(big.NewInt(0)) == 0 { return nil, nil, big.NewInt(0), nil @@ -514,7 +515,7 @@ func (uv *UtxoVM) SubBalance(addr []byte, delta *big.Int) { } } -//获得一个账号的余额,inLock表示在调用此函数时已经对uv.mutex加过锁了 +// 获得一个账号的余额,inLock表示在调用此函数时已经对uv.mutex加过锁了 func (uv *UtxoVM) GetBalance(addr string) (*big.Int, error) { cachedBalance, ok := uv.BalanceCache.Get(addr) if ok { diff --git a/bcs/ledger/xledger/state/xmodel/dbutils.go b/bcs/ledger/xledger/state/xmodel/dbutils.go index 7579ad0b..4da043af 100644 --- a/bcs/ledger/xledger/state/xmodel/dbutils.go +++ b/bcs/ledger/xledger/state/xmodel/dbutils.go @@ -8,7 +8,7 @@ import ( kledger "github.com/xuperchain/xupercore/kernel/ledger" "github.com/xuperchain/xupercore/lib/storage/kvdb" - "github.com/golang/protobuf/proto" //nolint:staticcheck + "github.com/golang/protobuf/proto" //nolint:staticcheck ) // KVEngineType KV storage type diff --git a/bcs/ledger/xledger/state/xmodel/message.go b/bcs/ledger/xledger/state/xmodel/message.go index 6d6f50fc..739888f6 100644 --- a/bcs/ledger/xledger/state/xmodel/message.go +++ b/bcs/ledger/xledger/state/xmodel/message.go @@ -5,7 +5,7 @@ import ( "fmt" "reflect" - "github.com/golang/protobuf/proto" //nolint:staticcheck + "github.com/golang/protobuf/proto" //nolint:staticcheck ) var ( diff --git a/bcs/ledger/xledger/state/xmodel/message_test.go b/bcs/ledger/xledger/state/xmodel/message_test.go index 621ccbe7..69bfc6bf 100644 --- a/bcs/ledger/xledger/state/xmodel/message_test.go +++ b/bcs/ledger/xledger/state/xmodel/message_test.go @@ -4,7 +4,7 @@ import ( "math/big" "testing" - "github.com/golang/protobuf/proto" //nolint:staticcheck + "github.com/golang/protobuf/proto" //nolint:staticcheck pb "github.com/xuperchain/xupercore/protos" ) diff --git a/bcs/ledger/xledger/state/xmodel/versioned_data.go b/bcs/ledger/xledger/state/xmodel/versioned_data.go index 99e71422..65ff67e9 100644 --- a/bcs/ledger/xledger/state/xmodel/versioned_data.go +++ b/bcs/ledger/xledger/state/xmodel/versioned_data.go @@ -17,7 +17,7 @@ func parseVersion(version string) ([]byte, int, error) { return txid, offset, nil } -//GetTxidFromVersion parse version and fetch txid from version string +// GetTxidFromVersion parse version and fetch txid from version string func GetTxidFromVersion(version string) []byte { txid, _, err := parseVersion(version) if err != nil { diff --git a/bcs/ledger/xledger/state/xmodel/xmodel.go b/bcs/ledger/xledger/state/xmodel/xmodel.go index ec3a635b..3284d073 100644 --- a/bcs/ledger/xledger/state/xmodel/xmodel.go +++ b/bcs/ledger/xledger/state/xmodel/xmodel.go @@ -6,7 +6,7 @@ import ( "fmt" "sync" - rich "github.com/xuperchain/xupercore/bcs/ledger/xledger/batch" + rb "github.com/xuperchain/xupercore/bcs/ledger/xledger/batch" "github.com/xuperchain/xupercore/bcs/ledger/xledger/ledger" "github.com/xuperchain/xupercore/bcs/ledger/xledger/state/context" pb "github.com/xuperchain/xupercore/bcs/ledger/xledger/xldgpb" @@ -89,7 +89,7 @@ func (s *XModel) updateExtUtxo(tx *pb.Transaction, batch kvdb.Batch) error { } bucketAndKey := makeRawKey(txOut.Bucket, txOut.Key) valueVersion := MakeVersion(tx.Txid, int32(offset)) - richBatch := rich.NewRichBatch(batch) + richBatch := rb.NewRichBatch(batch) if isDelFlag(txOut.Value) { // TODO: deal with error _ = richBatch.SoftDeleteExtUtxo(bucketAndKey, valueVersion) @@ -144,7 +144,7 @@ func (s *XModel) UndoTx(tx *pb.Transaction, batch kvdb.Batch) error { version := GetVersionOfTxInput(txIn) inputVersionMap[rawKey] = version } - richBatch := rich.NewRichBatch(batch) + richBatch := rb.NewRichBatch(batch) for _, txOut := range tx.TxOutputsExt { if txOut.Bucket == TransientBucket { continue diff --git a/bcs/ledger/xledger/tx/topsort.go b/bcs/ledger/xledger/tx/topsort.go index 3fb227b2..0c672f1f 100644 --- a/bcs/ledger/xledger/tx/topsort.go +++ b/bcs/ledger/xledger/tx/topsort.go @@ -4,13 +4,14 @@ import ( pb "github.com/xuperchain/xupercore/bcs/ledger/xledger/xldgpb" ) -//交易依赖关系图 +// 交易依赖关系图 type TxGraph map[string][]string -//TopSortDFS 对依赖关系图进行拓扑排序 +// TopSortDFS 对依赖关系图进行拓扑排序 // 输入:依赖关系图,就是个map // 输出: order: 排序后的有序数组,依赖者排在前面,被依赖的排在后面 -// cyclic: 如果发现有环形依赖关系则输出这个数组 +// +// cyclic: 如果发现有环形依赖关系则输出这个数组 // // 实现参考: https://rosettacode.org/wiki/Topological_sort#Go // 在我们映射中,RefTx是边的源点 diff --git a/bcs/ledger/xledger/tx/tx.go b/bcs/ledger/xledger/tx/tx.go index f35955e0..f70e5e39 100644 --- a/bcs/ledger/xledger/tx/tx.go +++ b/bcs/ledger/xledger/tx/tx.go @@ -8,7 +8,7 @@ import ( "math/big" "time" - "github.com/golang/protobuf/proto" //nolint:staticcheck + "github.com/golang/protobuf/proto" //nolint:staticcheck "github.com/xuperchain/xupercore/bcs/ledger/xledger/def" "github.com/xuperchain/xupercore/bcs/ledger/xledger/ledger" @@ -291,7 +291,7 @@ func (t *Tx) SortUnconfirmedTx(sizeLimit int) ([]*pb.Transaction, []*pb.Transact return result, delayedTxs, nil } -//从disk还原unconfirm表到内存, 初始化的时候 +// 从disk还原unconfirm表到内存, 初始化的时候 func (t *Tx) LoadUnconfirmedTxFromDisk() error { iter := t.ldb.NewIteratorWithPrefix([]byte(pb.UnconfirmedTablePrefix)) defer iter.Release() diff --git a/bcs/ledger/xledger/xldgpb/xledger.pb.go b/bcs/ledger/xledger/xldgpb/xledger.pb.go index d7336007..36c9dd56 100644 --- a/bcs/ledger/xledger/xldgpb/xledger.pb.go +++ b/bcs/ledger/xledger/xldgpb/xledger.pb.go @@ -5,7 +5,7 @@ package xldgpb import ( fmt "fmt" - proto "github.com/golang/protobuf/proto" //nolint:staticcheck + proto "github.com/golang/protobuf/proto" //nolint:staticcheck protos "github.com/xuperchain/xupercore/protos" math "math" ) diff --git a/bcs/network/p2pv2/client.go b/bcs/network/p2pv2/client.go index a3179772..4cafa4f8 100644 --- a/bcs/network/p2pv2/client.go +++ b/bcs/network/p2pv2/client.go @@ -15,7 +15,7 @@ import ( "github.com/xuperchain/xupercore/lib/timer" pb "github.com/xuperchain/xupercore/protos" - "github.com/golang/protobuf/proto" //nolint:staticcheck + "github.com/golang/protobuf/proto" //nolint:staticcheck "github.com/libp2p/go-libp2p-core/peer" prom "github.com/prometheus/client_golang/prometheus" ) diff --git a/bcs/network/p2pv2/server.go b/bcs/network/p2pv2/server.go index 46d3642d..9d887f29 100644 --- a/bcs/network/p2pv2/server.go +++ b/bcs/network/p2pv2/server.go @@ -7,7 +7,7 @@ import ( "strings" "time" - "github.com/golang/protobuf/proto" //nolint:staticcheck + "github.com/golang/protobuf/proto" //nolint:staticcheck ipfsAddr "github.com/ipfs/go-ipfs-addr" "github.com/libp2p/go-libp2p" circuit "github.com/libp2p/go-libp2p-circuit" diff --git a/example/xchain/common/xchainpb/xchain.pb.go b/example/xchain/common/xchainpb/xchain.pb.go index 96f76be8..cf246a5a 100644 --- a/example/xchain/common/xchainpb/xchain.pb.go +++ b/example/xchain/common/xchainpb/xchain.pb.go @@ -6,7 +6,7 @@ package xchainpb import ( context "context" fmt "fmt" - proto "github.com/golang/protobuf/proto" //nolint:staticcheck + proto "github.com/golang/protobuf/proto" //nolint:staticcheck xldgpb "github.com/xuperchain/xupercore/bcs/ledger/xledger/xldgpb" protos "github.com/xuperchain/xupercore/protos" grpc "google.golang.org/grpc" diff --git a/example/xchain/service/rpc/manage.go b/example/xchain/service/rpc/manage.go index d040ead8..a40f0579 100644 --- a/example/xchain/service/rpc/manage.go +++ b/example/xchain/service/rpc/manage.go @@ -21,13 +21,13 @@ import ( // rpc server启停控制管理 type RpcServMG struct { - scfg *sconf.ServConf - engine ecom.Engine - log logs.Logger - rpcServ *RpcServ - servHD *grpc.Server - isInit bool - exitOnce *sync.Once + scfg *sconf.ServConf + engine ecom.Engine + log logs.Logger + rpcServ *RpcServ + servHD *grpc.Server + isInit bool + exitOnce *sync.Once } func NewRpcServMG(scfg *sconf.ServConf, engine engines.BCEngine) (*RpcServMG, error) { diff --git a/kernel/consensus/base/common/common.go b/kernel/consensus/base/common/common.go index 065af745..431f8bb4 100644 --- a/kernel/consensus/base/common/common.go +++ b/kernel/consensus/base/common/common.go @@ -68,7 +68,7 @@ func CleanProduceMap(isProduce map[int64]bool, period int64) { } } -///////////////////// lpb兼容逻辑 ///////////////////// +// /////////////////// lpb兼容逻辑 ///////////////////// // 历史共识存储字段 type ConsensusStorage struct { Justify *lpb.QuorumCert `json:"justify,omitempty"` diff --git a/kernel/consensus/base/driver/chained-bft/mock/main_test.go b/kernel/consensus/base/driver/chained-bft/mock/main_test.go index 9b4e42bb..862d783d 100644 --- a/kernel/consensus/base/driver/chained-bft/mock/main_test.go +++ b/kernel/consensus/base/driver/chained-bft/mock/main_test.go @@ -75,14 +75,16 @@ func TestUpdateCommit(t *testing.T) { } // TestDFSQueryNode Tree如下 -// --------------------root ([]byte{0}, 0)----------------------- -// | | | +// +// --------------------root ([]byte{0}, 0)----------------------- +// | | | +// // (([]byte{1}, 1)) node1 node12 ([]byte{2}, 1) orphan4<[]byte{10}, 1> -// | | \ -// ([]byte{3}, 2) node2 orphan2<[]byte{30}, 2> orphan3<[]byte{35}, 2> -// | -// orphan1<[]byte{40}, 3> // +// | | \ +// ([]byte{3}, 2) node2 orphan2<[]byte{30}, 2> orphan3<[]byte{35}, 2> +// | +// orphan1<[]byte{40}, 3> func TestInsertOrphan(t *testing.T) { tree := PrepareTree(t) orphan1 := &storage.ProposalNode{ diff --git a/kernel/consensus/base/driver/chained-bft/pb/chainedBFTMsg.pb.go b/kernel/consensus/base/driver/chained-bft/pb/chainedBFTMsg.pb.go index e64dbd87..7fc1a4f8 100644 --- a/kernel/consensus/base/driver/chained-bft/pb/chainedBFTMsg.pb.go +++ b/kernel/consensus/base/driver/chained-bft/pb/chainedBFTMsg.pb.go @@ -5,7 +5,7 @@ package chainedBftPb import ( fmt "fmt" - proto "github.com/golang/protobuf/proto" //nolint:staticcheck + proto "github.com/golang/protobuf/proto" //nolint:staticcheck math "math" ) diff --git a/kernel/contract/bridge/memrpc/server.go b/kernel/contract/bridge/memrpc/server.go index 3abd935f..72584610 100644 --- a/kernel/contract/bridge/memrpc/server.go +++ b/kernel/contract/bridge/memrpc/server.go @@ -6,7 +6,7 @@ import ( "fmt" "reflect" - "github.com/golang/protobuf/proto" //nolint:staticcheck + "github.com/golang/protobuf/proto" //nolint:staticcheck pb "github.com/xuperchain/xupercore/kernel/contract/bridge/pb" ) diff --git a/kernel/contract/bridge/pb/contract.pb.go b/kernel/contract/bridge/pb/contract.pb.go index 9ad5ac38..333838e1 100644 --- a/kernel/contract/bridge/pb/contract.pb.go +++ b/kernel/contract/bridge/pb/contract.pb.go @@ -5,7 +5,7 @@ package pb import ( fmt "fmt" - proto "github.com/golang/protobuf/proto" //nolint:staticcheck + proto "github.com/golang/protobuf/proto" //nolint:staticcheck math "math" ) diff --git a/kernel/contract/bridge/pbrpc/contract_service.pb.go b/kernel/contract/bridge/pbrpc/contract_service.pb.go index 5278c206..6afa616d 100644 --- a/kernel/contract/bridge/pbrpc/contract_service.pb.go +++ b/kernel/contract/bridge/pbrpc/contract_service.pb.go @@ -6,7 +6,7 @@ package pbrpc import ( context "context" fmt "fmt" - proto "github.com/golang/protobuf/proto" //nolint:staticcheck + proto "github.com/golang/protobuf/proto" //nolint:staticcheck pb "github.com/xuperchain/xupercore/kernel/contract/bridge/pb" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" diff --git a/kernel/contract/manager.go b/kernel/contract/manager.go index de43e62f..03ff16e0 100644 --- a/kernel/contract/manager.go +++ b/kernel/contract/manager.go @@ -4,8 +4,8 @@ import ( "fmt" "sync" - "github.com/xuperchain/xupercore/kernel/contract/bridge/pb" "github.com/xuperchain/xupercore/kernel/common/xconfig" + "github.com/xuperchain/xupercore/kernel/contract/bridge/pb" "github.com/xuperchain/xupercore/kernel/ledger" ) diff --git a/kernel/contract/mock/helper.go b/kernel/contract/mock/helper.go index 3f976e08..aaf599f2 100644 --- a/kernel/contract/mock/helper.go +++ b/kernel/contract/mock/helper.go @@ -8,7 +8,7 @@ import ( "math/big" "os" - "github.com/golang/protobuf/proto" //nolint:staticcheck + "github.com/golang/protobuf/proto" //nolint:staticcheck "github.com/xuperchain/xupercore/kernel/contract" "github.com/xuperchain/xupercore/kernel/contract/sandbox" "github.com/xuperchain/xupercore/kernel/ledger" diff --git a/kernel/contract/sandbox/mem_xmodel.go b/kernel/contract/sandbox/mem_xmodel.go index bfdb6d53..d5ad34cd 100644 --- a/kernel/contract/sandbox/mem_xmodel.go +++ b/kernel/contract/sandbox/mem_xmodel.go @@ -31,7 +31,7 @@ func NewMemXModel() *MemXModel { } } -//读取一个key的值,返回的value就是有版本的data +// 读取一个key的值,返回的value就是有版本的data func (m *MemXModel) Get(bucket string, key []byte) (*ledger.VersionedData, error) { buKey := makeRawKey(bucket, key) v, ok := m.tree.Get(buKey) diff --git a/kernel/contract/sandbox/xmcache.go b/kernel/contract/sandbox/xmcache.go index a915fc21..fce79892 100644 --- a/kernel/contract/sandbox/xmcache.go +++ b/kernel/contract/sandbox/xmcache.go @@ -229,7 +229,7 @@ func (xc *XMCache) Transfer(from, to string, amount *big.Int) error { return xc.utxoSandbox.Transfer(from, to, amount) } -//UTXORWSet returns the inputs and outputs of utxo +// UTXORWSet returns the inputs and outputs of utxo func (xc *XMCache) UTXORWSet() *contract.UTXORWSet { return xc.utxoSandbox.GetUTXORWSets() } diff --git a/kernel/engines/xuperos/asyncworker/asyncworker_impl.go b/kernel/engines/xuperos/asyncworker/asyncworker_impl.go index 6a173fb4..0a52bc43 100644 --- a/kernel/engines/xuperos/asyncworker/asyncworker_impl.go +++ b/kernel/engines/xuperos/asyncworker/asyncworker_impl.go @@ -8,7 +8,7 @@ import ( "sync" "time" - "github.com/golang/protobuf/proto" //nolint:staticcheck + "github.com/golang/protobuf/proto" //nolint:staticcheck "github.com/xuperchain/xupercore/bcs/ledger/xledger/def" "github.com/xuperchain/xupercore/kernel/engines/xuperos/common" "github.com/xuperchain/xupercore/kernel/engines/xuperos/event" diff --git a/kernel/engines/xuperos/asyncworker/asyncworker_test.go b/kernel/engines/xuperos/asyncworker/asyncworker_test.go index 09acdeec..478c853d 100644 --- a/kernel/engines/xuperos/asyncworker/asyncworker_test.go +++ b/kernel/engines/xuperos/asyncworker/asyncworker_test.go @@ -153,10 +153,10 @@ func TestCursor(t *testing.T) { t.Errorf("reloadCursor value error") return } - err =aw.storeCursor(asyncWorkerCursor{ + err = aw.storeCursor(asyncWorkerCursor{ BlockHeight: 10, }) - if err != nil { + if err != nil { t.Fatal(err) } } diff --git a/kernel/engines/xuperos/miner/miner.go b/kernel/engines/xuperos/miner/miner.go index a5875024..f9259418 100644 --- a/kernel/engines/xuperos/miner/miner.go +++ b/kernel/engines/xuperos/miner/miner.go @@ -9,7 +9,7 @@ import ( "sync" "time" - "github.com/golang/protobuf/proto" //nolint:staticcheck + "github.com/golang/protobuf/proto" //nolint:staticcheck "github.com/patrickmn/go-cache" "github.com/xuperchain/xupercore/bcs/ledger/xledger/state" diff --git a/kernel/engines/xuperos/miner/sync.go b/kernel/engines/xuperos/miner/sync.go index 0cf369eb..221f8eb4 100644 --- a/kernel/engines/xuperos/miner/sync.go +++ b/kernel/engines/xuperos/miner/sync.go @@ -9,7 +9,7 @@ import ( "sort" "time" - "github.com/golang/protobuf/proto" //nolint:staticcheck + "github.com/golang/protobuf/proto" //nolint:staticcheck "github.com/xuperchain/xupercore/bcs/consensus/tdpos" "github.com/xuperchain/xupercore/bcs/ledger/xledger/ledger" "github.com/xuperchain/xupercore/bcs/ledger/xledger/state" diff --git a/kernel/engines/xuperos/net/net_event.go b/kernel/engines/xuperos/net/net_event.go index 20bd3fa7..a1731350 100644 --- a/kernel/engines/xuperos/net/net_event.go +++ b/kernel/engines/xuperos/net/net_event.go @@ -8,7 +8,7 @@ import ( "sync" "time" - "github.com/golang/protobuf/proto" //nolint:staticcheck + "github.com/golang/protobuf/proto" //nolint:staticcheck lpb "github.com/xuperchain/xupercore/bcs/ledger/xledger/xldgpb" xctx "github.com/xuperchain/xupercore/kernel/common/xcontext" "github.com/xuperchain/xupercore/kernel/engines/xuperos/common" @@ -266,7 +266,7 @@ func (t *NetEvent) handleNewBlockID(ctx xctx.XContext, request *protos.XuperMess } // sendMessage wrapper function which ignore error -func sendMessage(n network.Network, ctx xctx.XContext, msg *protos.XuperMessage, of ...p2p.OptionFunc) { +func sendMessage(n network.Network, ctx xctx.XContext, msg *protos.XuperMessage, of ...p2p.OptionFunc) { // ignore error _ = n.SendMessage(ctx, msg, of...) } diff --git a/kernel/engines/xuperos/net/validata.go b/kernel/engines/xuperos/net/validata.go index 067e40f6..7b16afd8 100644 --- a/kernel/engines/xuperos/net/validata.go +++ b/kernel/engines/xuperos/net/validata.go @@ -3,7 +3,7 @@ package xuperos import ( "errors" - "github.com/golang/protobuf/proto" //nolint:staticcheck + "github.com/golang/protobuf/proto" //nolint:staticcheck lpb "github.com/xuperchain/xupercore/bcs/ledger/xledger/xldgpb" ) diff --git a/kernel/engines/xuperos/parachain/parachain_contract.go b/kernel/engines/xuperos/parachain/parachain_contract.go index f05cfb49..d4eca7cc 100644 --- a/kernel/engines/xuperos/parachain/parachain_contract.go +++ b/kernel/engines/xuperos/parachain/parachain_contract.go @@ -308,7 +308,7 @@ func (p *paraChainContract) parseArgs(args map[string][]byte) (string, string, * return bcName, bcData, &bcGroup, nil } -//////////// Group /////////// +// ////////// Group /////////// type Group struct { GroupID string `json:"name,omitempty"` Admin []string `json:"admin,omitempty"` diff --git a/kernel/engines/xuperos/xpb/xpb.pb.go b/kernel/engines/xuperos/xpb/xpb.pb.go index 10c7a49c..b654ce0b 100644 --- a/kernel/engines/xuperos/xpb/xpb.pb.go +++ b/kernel/engines/xuperos/xpb/xpb.pb.go @@ -5,7 +5,7 @@ package xpb import ( fmt "fmt" - proto "github.com/golang/protobuf/proto" //nolint:staticcheck + proto "github.com/golang/protobuf/proto" //nolint:staticcheck xldgpb "github.com/xuperchain/xupercore/bcs/ledger/xledger/xldgpb" math "math" ) diff --git a/kernel/network/p2p/message.go b/kernel/network/p2p/message.go index 0921b817..b76e8507 100644 --- a/kernel/network/p2p/message.go +++ b/kernel/network/p2p/message.go @@ -6,7 +6,7 @@ import ( "github.com/xuperchain/xupercore/kernel/network/def" - "github.com/golang/protobuf/proto" //nolint:staticcheck + "github.com/golang/protobuf/proto" //nolint:staticcheck "github.com/golang/snappy" "github.com/xuperchain/xupercore/lib/utils" diff --git a/lib/cache/lru_cache.go b/lib/cache/lru_cache.go index 1e7829d5..6f811ca3 100644 --- a/lib/cache/lru_cache.go +++ b/lib/cache/lru_cache.go @@ -54,10 +54,11 @@ func NewLRUCache(capacity int) *LRUCache { // Get get cached value from LRU cache // Params: -// - key: cache key +// - key: cache key +// // Return: -// - value: cache value -// - ok : true if found, false if not +// - value: cache value +// - ok : true if found, false if not func (c *LRUCache) Get(key interface{}) (interface{}, bool) { c.lock.Lock() defer c.lock.Unlock() @@ -70,10 +71,11 @@ func (c *LRUCache) Get(key interface{}) (interface{}, bool) { // Add add a key-value pair to LRU cache // Params: -// - key : cache key -// - value: cache value +// - key : cache key +// - value: cache value +// // Return: -// - evictOrNot: true if eviction occurs, false if not +// - evictOrNot: true if eviction occurs, false if not func (c *LRUCache) Add(key interface{}, value interface{}) bool { c.lock.Lock() defer c.lock.Unlock() @@ -107,7 +109,7 @@ func (c *LRUCache) evict() { // Del delete cached value from cache // Params: -// - key: cache key +// - key: cache key func (c *LRUCache) Del(key interface{}) { c.lock.Lock() defer c.lock.Unlock() diff --git a/lib/storage/kvdb/badger/badger_impl.go b/lib/storage/kvdb/badger/badger_impl.go index 56565a1e..4225e315 100644 --- a/lib/storage/kvdb/badger/badger_impl.go +++ b/lib/storage/kvdb/badger/badger_impl.go @@ -1,5 +1,5 @@ -//badger wrapper plugin -//so +// badger wrapper plugin +// so package badgerdb import ( diff --git a/lib/storage/kvdb/leveldb/ldb_impl.go b/lib/storage/kvdb/leveldb/ldb_impl.go index 228c964c..59b1c624 100644 --- a/lib/storage/kvdb/leveldb/ldb_impl.go +++ b/lib/storage/kvdb/leveldb/ldb_impl.go @@ -9,8 +9,8 @@ import ( ) var ( -//ldbp = pprof.NewProfile("ldb") -//pcounter int64 +// ldbp = pprof.NewProfile("ldb") +// pcounter int64 ) // LDBDatabase define data structure of storage diff --git a/lib/storage/kvdb/leveldb/ldb_impl_test.go b/lib/storage/kvdb/leveldb/ldb_impl_test.go index 3daaba9b..6e46ab1e 100644 --- a/lib/storage/kvdb/leveldb/ldb_impl_test.go +++ b/lib/storage/kvdb/leveldb/ldb_impl_test.go @@ -153,7 +153,7 @@ func BenchmarkLdbBatch_GetNotExist(b *testing.B) { key := RandBytes(64) for i := 0; i < b.N; i++ { - _, _ =db.Get(key) + _, _ = db.Get(key) } } @@ -168,7 +168,7 @@ func BenchmarkLdbBatch_ParallelGetNotExist(b *testing.B) { key := RandBytes(64) b.RunParallel(func(pb *testing.PB) { for pb.Next() { - _, _ =db.Get(key) + _, _ = db.Get(key) } }) } diff --git a/lib/storage/mstorage/file_storage_nacl.go b/lib/storage/mstorage/file_storage_nacl.go index 4a957629..3c974fd4 100644 --- a/lib/storage/mstorage/file_storage_nacl.go +++ b/lib/storage/mstorage/file_storage_nacl.go @@ -4,6 +4,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +//go:build nacl // +build nacl package mstorage diff --git a/lib/storage/mstorage/file_storage_solaris.go b/lib/storage/mstorage/file_storage_solaris.go index 113988e4..18a42805 100644 --- a/lib/storage/mstorage/file_storage_solaris.go +++ b/lib/storage/mstorage/file_storage_solaris.go @@ -4,6 +4,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +//go:build solaris // +build solaris package mstorage diff --git a/lib/storage/mstorage/file_storage_unix.go b/lib/storage/mstorage/file_storage_unix.go index f52de780..e84257d3 100644 --- a/lib/storage/mstorage/file_storage_unix.go +++ b/lib/storage/mstorage/file_storage_unix.go @@ -4,6 +4,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd // +build darwin dragonfly freebsd linux netbsd openbsd package mstorage diff --git a/protos/contract.pb.go b/protos/contract.pb.go index 7673ced7..83c581ec 100644 --- a/protos/contract.pb.go +++ b/protos/contract.pb.go @@ -5,7 +5,7 @@ package protos import ( fmt "fmt" - proto "github.com/golang/protobuf/proto" //nolint:staticcheck + proto "github.com/golang/protobuf/proto" //nolint:staticcheck math "math" ) diff --git a/protos/event.pb.go b/protos/event.pb.go index 63d0ab7b..905cc991 100644 --- a/protos/event.pb.go +++ b/protos/event.pb.go @@ -6,7 +6,7 @@ package protos import ( context "context" fmt "fmt" - proto "github.com/golang/protobuf/proto" //nolint:staticcheck + proto "github.com/golang/protobuf/proto" //nolint:staticcheck grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" diff --git a/protos/ledger.pb.go b/protos/ledger.pb.go index 5b274229..8734eb9c 100644 --- a/protos/ledger.pb.go +++ b/protos/ledger.pb.go @@ -5,7 +5,7 @@ package protos import ( fmt "fmt" - proto "github.com/golang/protobuf/proto" //nolint:staticcheck + proto "github.com/golang/protobuf/proto" //nolint:staticcheck math "math" ) diff --git a/protos/network.pb.go b/protos/network.pb.go index 17bce8c6..c23c0c63 100644 --- a/protos/network.pb.go +++ b/protos/network.pb.go @@ -6,7 +6,7 @@ package protos import ( context "context" fmt "fmt" - proto "github.com/golang/protobuf/proto" //nolint:staticcheck + proto "github.com/golang/protobuf/proto" //nolint:staticcheck grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" diff --git a/protos/permission.pb.go b/protos/permission.pb.go index d5345e9f..193eefa6 100644 --- a/protos/permission.pb.go +++ b/protos/permission.pb.go @@ -5,7 +5,7 @@ package protos import ( fmt "fmt" - proto "github.com/golang/protobuf/proto" //nolint:staticcheck + proto "github.com/golang/protobuf/proto" //nolint:staticcheck math "math" ) diff --git a/protos/proposal.pb.go b/protos/proposal.pb.go index e74e1976..e80bb1a2 100644 --- a/protos/proposal.pb.go +++ b/protos/proposal.pb.go @@ -5,7 +5,7 @@ package protos import ( fmt "fmt" - proto "github.com/golang/protobuf/proto" //nolint:staticcheck + proto "github.com/golang/protobuf/proto" //nolint:staticcheck math "math" )