fix: remove unnecessary assignment

This commit is contained in:
Jianrong 2024-01-20 12:46:31 +11:00
parent 9bb8c8cfd4
commit 786e3793b0
2 changed files with 15 additions and 6 deletions

View file

@ -95,8 +95,14 @@ func NewMongoDBEngine(cfg *Config) *XDCxDAO.MongoDatabase {
}
func New(cfg *Config) *XDCX {
tokenDecimalCache, _ := lru.New(defaultCacheLimit)
orderCache, _ := lru.New(tradingstate.OrderCacheLimit)
tokenDecimalCache, err := lru.New(defaultCacheLimit)
if err != nil {
log.Warn("[XDCx-New] fail to create new lru for token decimal")
}
orderCache, err := lru.New(tradingstate.OrderCacheLimit)
if err != nil {
log.Warn("[XDCx-New] fail to create new lru for order")
}
XDCX := &XDCX{
orderNonce: make(map[common.Address]*big.Int),
Triegc: prque.New(),
@ -121,7 +127,10 @@ func New(cfg *Config) *XDCX {
// Overflow returns an indication if the message queue is full.
func (XDCx *XDCX) Overflow() bool {
val, _ := XDCx.settings.Load(overflowIdx)
val, ok := XDCx.settings.Load(overflowIdx)
if !ok {
log.Warn("[XDCx-Overflow] fail to load overflow index")
}
return val.(bool)
}
@ -639,7 +648,7 @@ func (XDCx *XDCX) RollbackReorgTxMatch(txhash common.Hash) error {
continue
}
orderCacheAtTxHash := c.(map[common.Hash]tradingstate.OrderHistoryItem)
orderHistoryItem, _ := orderCacheAtTxHash[tradingstate.GetOrderHistoryKey(order.BaseToken, order.QuoteToken, order.Hash)]
orderHistoryItem := orderCacheAtTxHash[tradingstate.GetOrderHistoryKey(order.BaseToken, order.QuoteToken, order.Hash)]
if (orderHistoryItem == tradingstate.OrderHistoryItem{}) {
log.Debug("XDCx reorg: remove order due to empty orderHistory", "order", tradingstate.ToJSON(order))
if err := db.DeleteObject(order.Hash, &tradingstate.OrderItem{}); err != nil {

View file

@ -764,7 +764,7 @@ func (l *Lending) RollbackLendingData(txhash common.Hash) error {
continue
}
cacheAtTxHash := c.(map[common.Hash]lendingstate.LendingItemHistoryItem)
lendingItemHistory, _ := cacheAtTxHash[lendingstate.GetLendingItemHistoryKey(item.LendingToken, item.CollateralToken, item.Hash)]
lendingItemHistory := cacheAtTxHash[lendingstate.GetLendingItemHistoryKey(item.LendingToken, item.CollateralToken, item.Hash)]
if (lendingItemHistory == lendingstate.LendingItemHistoryItem{}) {
log.Debug("XDCxlending reorg: remove item due to empty lendingItemHistory", "item", lendingstate.ToJSON(item))
if err := db.DeleteObject(item.Hash, &lendingstate.LendingItem{}); err != nil {
@ -797,7 +797,7 @@ func (l *Lending) RollbackLendingData(txhash common.Hash) error {
continue
}
cacheAtTxHash := c.(map[common.Hash]lendingstate.LendingTradeHistoryItem)
lendingTradeHistoryItem, _ := cacheAtTxHash[trade.Hash]
lendingTradeHistoryItem := cacheAtTxHash[trade.Hash]
if (lendingTradeHistoryItem == lendingstate.LendingTradeHistoryItem{}) {
log.Debug("XDCxlending reorg: remove trade due to empty LendingTradeHistory", "trade", lendingstate.ToJSON(trade))
if err := db.DeleteObject(trade.Hash, &lendingstate.LendingTrade{}); err != nil {