66 "encoding/hex"
77 "errors"
88 "fmt"
9- utils2 "github.com/xuperchain/xupercore/bcs/ledger/xledger/batch"
109 "math/big"
1110 "path/filepath"
1211 "runtime"
@@ -15,6 +14,7 @@ import (
1514
1615 "github.com/golang/protobuf/proto" //nolint:staticcheck
1716
17+ rb "github.com/xuperchain/xupercore/bcs/ledger/xledger/batch"
1818 "github.com/xuperchain/xupercore/bcs/ledger/xledger/def"
1919 pb "github.com/xuperchain/xupercore/bcs/ledger/xledger/xldgpb"
2020 "github.com/xuperchain/xupercore/lib/cache"
@@ -426,7 +426,7 @@ func (l *Ledger) correctTxsBlockid(blockID []byte, batchWrite kvdb.Batch) error
426426 l .xlog .Warn ("marshal trasaction failed when confirm block" , "err" , err )
427427 return err
428428 }
429- utils2 .NewRichBatch (batchWrite ).PutConfirmedTx (tx .Txid , pbTxBuf )
429+ rb .NewRichBatch (batchWrite ).PutConfirmedTx (tx .Txid , pbTxBuf )
430430 }
431431 }
432432 return nil
@@ -722,7 +722,7 @@ func (l *Ledger) ConfirmBlock(block *pb.InternalBlock, isRoot bool) ConfirmStatu
722722 cbNum := 0
723723 oldBlockCache := map [string ]* pb.InternalBlock {}
724724 trace ("checktx" )
725- richerBatch := utils2 .NewRichBatch (batchWrite )
725+ richBatch := rb .NewRichBatch (batchWrite )
726726 for i , tx := range realTransactions {
727727 if tx .Coinbase {
728728 cbNum = cbNum + 1
@@ -742,7 +742,7 @@ func (l *Ledger) ConfirmBlock(block *pb.InternalBlock, isRoot bool) ConfirmStatu
742742 }
743743 hasTx := txExist [string (tx .Txid )]
744744 if ! hasTx {
745- richerBatch .PutConfirmedTx (tx .Txid , pbTxBuf )
745+ richBatch .PutConfirmedTx (tx .Txid , pbTxBuf )
746746 } else {
747747 //confirm表已经存在这个交易了,需要检查一下是否存在多个主干block包含同样transaction的情况
748748 oldPbTxBuf , _ := l .confirmedTable .Get (tx .Txid )
@@ -761,7 +761,7 @@ func (l *Ledger) ConfirmBlock(block *pb.InternalBlock, isRoot bool) ConfirmStatu
761761 if blockErr != nil {
762762 if def .NormalizedKVError (blockErr ) == def .ErrKVNotFound {
763763 l .xlog .Warn ("old block that contains the tx has been truncated" , "txid" , utils .F (tx .Txid ), "blockid" , utils .F (oldTx .Blockid ))
764- richerBatch .PutConfirmedTx (tx .Txid , pbTxBuf ) //overwrite with newtx
764+ richBatch .PutConfirmedTx (tx .Txid , pbTxBuf ) //overwrite with newtx
765765 continue
766766 }
767767 confirmStatus .Succ = false
@@ -785,7 +785,7 @@ func (l *Ledger) ConfirmBlock(block *pb.InternalBlock, isRoot bool) ConfirmStatu
785785 return confirmStatus
786786 } else if block .InTrunk {
787787 l .xlog .Info ("change blockid of tx" , "txid" , utils .F (tx .Txid ), "blockid" , utils .F (block .Blockid ))
788- richerBatch .PutConfirmedTx (tx .Txid , pbTxBuf )
788+ richBatch .PutConfirmedTx (tx .Txid , pbTxBuf )
789789 }
790790 }
791791 }
@@ -802,7 +802,7 @@ func (l *Ledger) ConfirmBlock(block *pb.InternalBlock, isRoot bool) ConfirmStatu
802802 return confirmStatus
803803 }
804804 // TODO: deal with error
805- _ = richerBatch .PutMeta ("" , metaBuf )
805+ _ = richBatch .PutMeta ("" , metaBuf )
806806 l .xlog .Debug ("print block size when confirm block" , "blockSize" , batchWrite .ValueSize (), "blockid" , utils .F (block .Blockid ))
807807 kvErr := batchWrite .Write () // blocks, confirmed_transaction两张表原子写入
808808 blkTimer .Mark ("saveToDisk" )
@@ -1241,7 +1241,7 @@ func (l *Ledger) Truncate(utxovmLastID []byte) error {
12411241 l .xlog .Warn ("failed to marshal pb meta" )
12421242 return err
12431243 }
1244- if err := utils2 .NewRichBatch (batchWrite ).PutMeta ("" , metaBuf ); err != nil {
1244+ if err := rb .NewRichBatch (batchWrite ).PutMeta ("" , metaBuf ); err != nil {
12451245 return err
12461246 }
12471247 err = batchWrite .Write ()
0 commit comments