Skip to content

Commit ddac0a6

Browse files
authored
Merge pull request #399 from XinFinOrg/xdp-01
fix: remove unnecessary assignment
2 parents 9bb8c8c + 71c4425 commit ddac0a6

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

XDCx/XDCx.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,14 @@ func NewMongoDBEngine(cfg *Config) *XDCxDAO.MongoDatabase {
9595
}
9696

9797
func New(cfg *Config) *XDCX {
98-
tokenDecimalCache, _ := lru.New(defaultCacheLimit)
99-
orderCache, _ := lru.New(tradingstate.OrderCacheLimit)
98+
tokenDecimalCache, err := lru.New(defaultCacheLimit)
99+
if err != nil {
100+
log.Warn("[XDCx-New] fail to create new lru for token decimal", "error", err)
101+
}
102+
orderCache, err := lru.New(tradingstate.OrderCacheLimit)
103+
if err != nil {
104+
log.Warn("[XDCx-New] fail to create new lru for order", "error", err)
105+
}
100106
XDCX := &XDCX{
101107
orderNonce: make(map[common.Address]*big.Int),
102108
Triegc: prque.New(),
@@ -121,7 +127,10 @@ func New(cfg *Config) *XDCX {
121127

122128
// Overflow returns an indication if the message queue is full.
123129
func (XDCx *XDCX) Overflow() bool {
124-
val, _ := XDCx.settings.Load(overflowIdx)
130+
val, ok := XDCx.settings.Load(overflowIdx)
131+
if !ok {
132+
log.Warn("[XDCx-Overflow] fail to load overflow index")
133+
}
125134
return val.(bool)
126135
}
127136

@@ -639,7 +648,7 @@ func (XDCx *XDCX) RollbackReorgTxMatch(txhash common.Hash) error {
639648
continue
640649
}
641650
orderCacheAtTxHash := c.(map[common.Hash]tradingstate.OrderHistoryItem)
642-
orderHistoryItem, _ := orderCacheAtTxHash[tradingstate.GetOrderHistoryKey(order.BaseToken, order.QuoteToken, order.Hash)]
651+
orderHistoryItem := orderCacheAtTxHash[tradingstate.GetOrderHistoryKey(order.BaseToken, order.QuoteToken, order.Hash)]
643652
if (orderHistoryItem == tradingstate.OrderHistoryItem{}) {
644653
log.Debug("XDCx reorg: remove order due to empty orderHistory", "order", tradingstate.ToJSON(order))
645654
if err := db.DeleteObject(order.Hash, &tradingstate.OrderItem{}); err != nil {

XDCxlending/XDCxlending.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ func (l *Lending) RollbackLendingData(txhash common.Hash) error {
764764
continue
765765
}
766766
cacheAtTxHash := c.(map[common.Hash]lendingstate.LendingItemHistoryItem)
767-
lendingItemHistory, _ := cacheAtTxHash[lendingstate.GetLendingItemHistoryKey(item.LendingToken, item.CollateralToken, item.Hash)]
767+
lendingItemHistory := cacheAtTxHash[lendingstate.GetLendingItemHistoryKey(item.LendingToken, item.CollateralToken, item.Hash)]
768768
if (lendingItemHistory == lendingstate.LendingItemHistoryItem{}) {
769769
log.Debug("XDCxlending reorg: remove item due to empty lendingItemHistory", "item", lendingstate.ToJSON(item))
770770
if err := db.DeleteObject(item.Hash, &lendingstate.LendingItem{}); err != nil {
@@ -797,7 +797,7 @@ func (l *Lending) RollbackLendingData(txhash common.Hash) error {
797797
continue
798798
}
799799
cacheAtTxHash := c.(map[common.Hash]lendingstate.LendingTradeHistoryItem)
800-
lendingTradeHistoryItem, _ := cacheAtTxHash[trade.Hash]
800+
lendingTradeHistoryItem := cacheAtTxHash[trade.Hash]
801801
if (lendingTradeHistoryItem == lendingstate.LendingTradeHistoryItem{}) {
802802
log.Debug("XDCxlending reorg: remove trade due to empty LendingTradeHistory", "trade", lendingstate.ToJSON(trade))
803803
if err := db.DeleteObject(trade.Hash, &lendingstate.LendingTrade{}); err != nil {

0 commit comments

Comments
 (0)