Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade package common #768

Merged
merged 63 commits into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
89c51c5
common: improve documentation comments (#16701)
gzliudan Dec 18, 2024
7cd3e56
accounts/abi/bind: stop using goimports in the binding generator (#17…
gzliudan Dec 12, 2024
c0f547c
cmd/utils: fix bug when checking for flag value conflicts (#17803)
gzliudan Dec 13, 2024
e58441b
accounts/abi: change unpacking of abi fields w/ underscores (#16513)
gzliudan Dec 12, 2024
75c14d2
accounts/abi: fix case of generated java functions (#18372)
gzliudan Dec 12, 2024
2772e09
common/compiler: fixed testSource (#18978)
jasagredo Feb 3, 2019
f19422e
cmd/utils: relinquish GC cache to read cache in archive mode (#18991)
gzliudan Dec 11, 2024
cd1ff5d
common: remove function Big() for type Address (#19210)
gzliudan Dec 11, 2024
6692189
cmd/abigen: support Vyper (#19120)
gzliudan Dec 12, 2024
a747a98
common: improve functions of StorageSize (#19244)
gzliudan Dec 12, 2024
b711dc8
cmd/abigen: allow using abigen --pkg flag with standard input (#19207)
gzliudan Dec 13, 2024
91570dc
accounts/abi: fix mobile interface (#19180)
gzliudan Dec 12, 2024
7455b91
accounts/abi/bind: accept function ptr parameter (#19755)
gzliudan Dec 12, 2024
993bc69
accounts/abi/bind: link dependent libs in deploy (#19718)
gzliudan Dec 13, 2024
d6957d9
accounts/abi/bind: remove test case UseLibrary
gzliudan Dec 13, 2024
057a7dd
cmd/abigen: refactor command line interface (#19797)
gzliudan Dec 13, 2024
5a8110b
common/bitutil: use result of TestBytes to prevent dead code eliminat…
dr2chase Jul 17, 2019
94b69fd
common/compiler: support relative import paths (#17374 #19967)
shiqinfeng1 Aug 15, 2019
7f63a69
common: unify hex prefix check code (#19937)
gzliudan Dec 16, 2024
56e242b
core/state: optimize some internals during encoding (#20038)
gzliudan Dec 16, 2024
f5e90ee
common: improve test (#20354)
gzliudan Dec 16, 2024
30f835c
accounts/abi: common/math: moved U256Bytes (#21020)
gzliudan Dec 19, 2024
d3a943d
common/math: use math/bits intrinsics for Safe* (#21316)
fjl Jul 9, 2020
cf0c5c8
common/prque: refactor LazyQueue (#21236)
gzliudan Dec 16, 2024
28739d7
common: remove usage of deprecated function (#21610)
gzliudan Dec 16, 2024
dd318fc
common/hexutil: remove redundant conversion (#21903)
gzliudan Dec 16, 2024
c2db0e4
common: improve printing of Hash and Address (#21834)
gzliudan Dec 17, 2024
f01e639
common/compiler: fix parsing of solc output with solidity v.0.8.0 (#2…
MariusVanDerWijden Jan 5, 2021
d852f8c
common/prque: pull in tests and benchmarks from upstream (#22157)
karalabe Jan 11, 2021
6f19ace
common/mclock: remove dependency on github.com/aristanetworks/goarist…
gzliudan Dec 17, 2024
e52587d
common: do not pass current time as param in priority funcs (#22183)
gzliudan Dec 17, 2024
e2eb22d
common/prque: make Prque wrap-around priority handling optional (#22495)
gzliudan Dec 17, 2024
fb17f56
common: rename unused function with typo (#23025)
paularmand Jun 10, 2021
4db72a0
common: fixes format verb (#23495)
AlexanderYastrebov Aug 31, 2021
49dc5e8
common/hexutil: improve performance of EncodeBig (#23780)
lmittmann Oct 21, 2021
69ea532
common/compiler: add extra include paths to solidity compiler (#24541)
zhiqiangxu Mar 29, 2022
d6d6906
internal: add db operations to api (#24739)
gzliudan Dec 17, 2024
ebc0366
common/compiler, cmd/abigen: remove solc/vyper compiler integration (…
gzliudan Dec 17, 2024
febb456
common: improve pretty duration regex (#25073)
MariusVanDerWijden Jun 14, 2022
a03e111
common: increase StorageSize test coverage (#25188)
dbadoy Jun 29, 2022
1bff428
common/prque: fix typo (#25206)
dbadoy Jun 30, 2022
e3edcc8
common/math: lint whitespace
gzliudan Dec 17, 2024
32e033d
common, p2p: use AbsTime.Add instead of conversion (#25417)
gzliudan Dec 17, 2024
3eb2ec4
common/compiler: json unmarshalling error checks (#25449)
henry-0 Aug 1, 2022
5059114
common/types: add `Address.Big` (#26132)
tynes Nov 8, 2022
39e9d8f
common/prque: generic priority queue (#26290)
karalabe Feb 9, 2023
b58802a
common/math: allow HexOrDecimal to accept unquoted decimals too (#26758)
karalabe Feb 22, 2023
12111d3
common: delete MakeName (#27023)
lightclient Apr 3, 2023
59b14ed
internal/ethapi: make NewAccount return EIP-55 format (#26973)
gzliudan Dec 18, 2024
f74cccd
beacon/types: add beacon chain data types (#27292)
zsfelfoldi May 17, 2023
441f8ed
common: add variable MaxHash (#28306)
gzliudan Dec 19, 2024
4cc2b2e
tests/fuzzers: move fuzzers into native packages (#28467)
gzliudan Dec 19, 2024
ff13d16
core/vm: make structlog/json-log stack hex again (#28628)
gzliudan Dec 19, 2024
f2cd7c0
common/math: copy result in Exp (#29233)
AaronChen0 Mar 12, 2024
009542a
accounts/usbwallet, common/bitutil: fix broken links in docs (#29078)
justindhillon Mar 13, 2024
57eb92d
common/prque: remove dependency on golang.org/exp (#29314)
gzliudan Dec 19, 2024
62afcf6
common/prque: fix godoc comments (#29460)
georgehao Apr 6, 2024
b274a27
common/math: rename variable name `int` to `n` (#29890)
tianyeyouyou May 31, 2024
6fda80a
common/math: fix out of bounds access in json unmarshalling (#30014)
decanus Jun 17, 2024
dff8e50
common: using `ParseUint` instead of `ParseInt` (#30020)
Halimao Jun 19, 2024
6ec35b9
all: get rid of custom MaxUint64 and MaxUint64 (#30636)
gzliudan Dec 19, 2024
156de2b
common/math: delete some further dead code (#30639)
gzliudan Dec 19, 2024
6e33633
common: drop BigMin and BigMax, they pollute our dep graph (#30645)
gzliudan Dec 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions XDCx/XDCx.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ type XDCX struct {
// Order related
db XDCxDAO.XDCXDAO
mongodb XDCxDAO.XDCXDAO
Triegc *prque.Prque // Priority queue mapping block numbers to tries to gc
StateCache tradingstate.Database // State database to reuse between imports (contains state cache) *XDCx_state.TradingStateDB
Triegc *prque.Prque[int64, common.Hash] // Priority queue mapping block numbers to tries to gc
StateCache tradingstate.Database // State database to reuse between imports (contains state cache) *XDCx_state.TradingStateDB

orderNonce map[common.Address]*big.Int

Expand Down Expand Up @@ -94,7 +94,7 @@ func NewMongoDBEngine(cfg *Config) *XDCxDAO.MongoDatabase {
func New(cfg *Config) *XDCX {
XDCX := &XDCX{
orderNonce: make(map[common.Address]*big.Int),
Triegc: prque.New(nil),
Triegc: prque.New[int64, common.Hash](nil),
tokenDecimalCache: lru.NewCache[common.Address, *big.Int](defaultCacheLimit),
orderCache: lru.NewCache[common.Hash, map[common.Hash]tradingstate.OrderHistoryItem](tradingstate.OrderCacheLimit),
}
Expand Down Expand Up @@ -579,7 +579,7 @@ func (XDCx *XDCX) HasTradingState(block *types.Block, author common.Address) boo
return err == nil
}

func (XDCx *XDCX) GetTriegc() *prque.Prque {
func (XDCx *XDCX) GetTriegc() *prque.Prque[int64, common.Hash] {
return XDCx.Triegc
}

Expand Down
2 changes: 1 addition & 1 deletion XDCx/order_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ func DoSettleBalance(coinbase common.Address, takerOrder, makerOrder *tradingsta
matchingFee = new(big.Int).Add(matchingFee, common.RelayerFee)
matchingFee = new(big.Int).Add(matchingFee, common.RelayerFee)

if common.EmptyHash(takerExOwner.Hash()) || common.EmptyHash(makerExOwner.Hash()) {
if takerExOwner.Hash().IsZero() || makerExOwner.Hash().IsZero() {
return fmt.Errorf("empty echange owner: taker: %v , maker : %v", takerExOwner, makerExOwner)
}
mapBalances := map[common.Address]map[common.Address]*big.Int{}
Expand Down
22 changes: 11 additions & 11 deletions XDCx/tradingstate/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (t *TradingStateDB) DumpAskTrie(orderBook common.Hash) (map[*big.Int]DumpOr
it := trie.NewIterator(exhangeObject.getAsksTrie(t.db).NodeIterator(nil))
for it.Next() {
priceHash := common.BytesToHash(it.Key)
if common.EmptyHash(priceHash) {
if priceHash.IsZero() {
continue
}
price := new(big.Int).SetBytes(priceHash.Bytes())
Expand Down Expand Up @@ -99,7 +99,7 @@ func (t *TradingStateDB) DumpBidTrie(orderBook common.Hash) (map[*big.Int]DumpOr
it := trie.NewIterator(exhangeObject.getBidsTrie(t.db).NodeIterator(nil))
for it.Next() {
priceHash := common.BytesToHash(it.Key)
if common.EmptyHash(priceHash) {
if priceHash.IsZero() {
continue
}
price := new(big.Int).SetBytes(priceHash.Bytes())
Expand Down Expand Up @@ -142,7 +142,7 @@ func (t *TradingStateDB) GetBids(orderBook common.Hash) (map[*big.Int]*big.Int,
it := trie.NewIterator(exhangeObject.getBidsTrie(t.db).NodeIterator(nil))
for it.Next() {
priceHash := common.BytesToHash(it.Key)
if common.EmptyHash(priceHash) {
if priceHash.IsZero() {
continue
}
price := new(big.Int).SetBytes(priceHash.Bytes())
Expand Down Expand Up @@ -185,7 +185,7 @@ func (t *TradingStateDB) GetAsks(orderBook common.Hash) (map[*big.Int]*big.Int,
it := trie.NewIterator(exhangeObject.getAsksTrie(t.db).NodeIterator(nil))
for it.Next() {
priceHash := common.BytesToHash(it.Key)
if common.EmptyHash(priceHash) {
if priceHash.IsZero() {
continue
}
price := new(big.Int).SetBytes(priceHash.Bytes())
Expand Down Expand Up @@ -224,7 +224,7 @@ func (s *stateOrderList) DumpOrderList(db Database) DumpOrderList {
orderListIt := trie.NewIterator(s.getTrie(db).NodeIterator(nil))
for orderListIt.Next() {
keyHash := common.BytesToHash(orderListIt.Key)
if common.EmptyHash(keyHash) {
if keyHash.IsZero() {
continue
}
if _, exist := s.cachedStorage[keyHash]; exist {
Expand All @@ -235,7 +235,7 @@ func (s *stateOrderList) DumpOrderList(db Database) DumpOrderList {
}
}
for key, value := range s.cachedStorage {
if !common.EmptyHash(value) {
if !value.IsZero() {
mapResult.Orders[new(big.Int).SetBytes(key.Bytes())] = new(big.Int).SetBytes(value.Bytes())
}
}
Expand Down Expand Up @@ -277,7 +277,7 @@ func (s *stateLendingBook) DumpOrderList(db Database) DumpOrderList {
orderListIt := trie.NewIterator(s.getTrie(db).NodeIterator(nil))
for orderListIt.Next() {
keyHash := common.BytesToHash(orderListIt.Key)
if common.EmptyHash(keyHash) {
if keyHash.IsZero() {
continue
}
if _, exist := s.cachedStorage[keyHash]; exist {
Expand All @@ -288,7 +288,7 @@ func (s *stateLendingBook) DumpOrderList(db Database) DumpOrderList {
}
}
for key, value := range s.cachedStorage {
if !common.EmptyHash(value) {
if !value.IsZero() {
mapResult.Orders[new(big.Int).SetBytes(key.Bytes())] = new(big.Int).SetBytes(value.Bytes())
}
}
Expand All @@ -311,7 +311,7 @@ func (l *liquidationPriceState) DumpLendingBook(db Database) (DumpLendingBook, e
it := trie.NewIterator(l.getTrie(db).NodeIterator(nil))
for it.Next() {
lendingBook := common.BytesToHash(it.Key)
if common.EmptyHash(lendingBook) {
if lendingBook.IsZero() {
continue
}
if _, exist := l.stateLendingBooks[lendingBook]; exist {
Expand All @@ -326,7 +326,7 @@ func (l *liquidationPriceState) DumpLendingBook(db Database) (DumpLendingBook, e
}
}
for lendingBook, stateLendingBook := range l.stateLendingBooks {
if !common.EmptyHash(lendingBook) {
if !lendingBook.IsZero() {
result.LendingBooks[lendingBook] = stateLendingBook.DumpOrderList(db)
}
}
Expand All @@ -342,7 +342,7 @@ func (t *TradingStateDB) DumpLiquidationPriceTrie(orderBook common.Hash) (map[*b
it := trie.NewIterator(exhangeObject.getLiquidationPriceTrie(t.db).NodeIterator(nil))
for it.Next() {
priceHash := common.BytesToHash(it.Key)
if common.EmptyHash(priceHash) {
if priceHash.IsZero() {
continue
}
price := new(big.Int).SetBytes(priceHash.Bytes())
Expand Down
2 changes: 1 addition & 1 deletion XDCx/tradingstate/state_lendingbook.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func (s *stateLendingBook) getAllTradeIds(db Database) []common.Hash {
return tradeIds
}
for id, value := range s.cachedStorage {
if !common.EmptyHash(value) {
if !value.IsZero() {
tradeIds = append(tradeIds, id)
}
}
Expand Down
8 changes: 4 additions & 4 deletions XDCx/tradingstate/state_orderbook.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,16 @@ func (te *tradingExchanges) empty() bool {
if te.data.TotalQuantity != nil && te.data.TotalQuantity.Sign() > 0 {
return false
}
if !common.EmptyHash(te.data.AskRoot) {
if !te.data.AskRoot.IsZero() {
return false
}
if !common.EmptyHash(te.data.BidRoot) {
if !te.data.BidRoot.IsZero() {
return false
}
if !common.EmptyHash(te.data.OrderRoot) {
if !te.data.OrderRoot.IsZero() {
return false
}
if !common.EmptyHash(te.data.LiquidationPriceRoot) {
if !te.data.LiquidationPriceRoot.IsZero() {
return false
}
return true
Expand Down
4 changes: 2 additions & 2 deletions XDCx/tradingstate/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ func (t *TradingStateDB) GetBestAskPrice(orderBook common.Hash) (*big.Int, *big.
stateObject := t.getStateExchangeObject(orderBook)
if stateObject != nil {
priceHash := stateObject.getBestPriceAsksTrie(t.db)
if common.EmptyHash(priceHash) {
if priceHash.IsZero() {
return Zero, Zero
}
orderList := stateObject.getStateOrderListAskObject(t.db, priceHash)
Expand All @@ -375,7 +375,7 @@ func (t *TradingStateDB) GetBestBidPrice(orderBook common.Hash) (*big.Int, *big.
stateObject := t.getStateExchangeObject(orderBook)
if stateObject != nil {
priceHash := stateObject.getBestBidsTrie(t.db)
if common.EmptyHash(priceHash) {
if priceHash.IsZero() {
return Zero, Zero
}
orderList := stateObject.getStateBidOrderListObject(t.db, priceHash)
Expand Down
7 changes: 4 additions & 3 deletions XDCx/tradingstate/statedb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ package tradingstate

import (
"fmt"
"github.com/XinFinOrg/XDPoSChain/common"
"github.com/XinFinOrg/XDPoSChain/common/math"
"github.com/XinFinOrg/XDPoSChain/core/rawdb"
"math"
"math/big"
"testing"

"github.com/XinFinOrg/XDPoSChain/common"
"github.com/XinFinOrg/XDPoSChain/core/rawdb"
)

func TestEchangeStates(t *testing.T) {
Expand Down
8 changes: 4 additions & 4 deletions XDCxlending/XDCxlending.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ var (
)

type Lending struct {
Triegc *prque.Prque // Priority queue mapping block numbers to tries to gc
StateCache lendingstate.Database // State database to reuse between imports (contains state cache) *lendingstate.TradingStateDB
Triegc *prque.Prque[int64, common.Hash] // Priority queue mapping block numbers to tries to gc
StateCache lendingstate.Database // State database to reuse between imports (contains state cache) *lendingstate.TradingStateDB

orderNonce map[common.Address]*big.Int

Expand All @@ -61,7 +61,7 @@ func (l *Lending) Stop() error {
func New(XDCx *XDCx.XDCX) *Lending {
lending := &Lending{
orderNonce: make(map[common.Address]*big.Int),
Triegc: prque.New(nil),
Triegc: prque.New[int64, common.Hash](nil),
lendingItemHistory: lru.NewCache[common.Hash, map[common.Hash]lendingstate.LendingItemHistoryItem](defaultCacheLimit),
lendingTradeHistory: lru.NewCache[common.Hash, map[common.Hash]lendingstate.LendingTradeHistoryItem](defaultCacheLimit),
}
Expand Down Expand Up @@ -682,7 +682,7 @@ func (l *Lending) HasLendingState(block *types.Block, author common.Address) boo
return err == nil
}

func (l *Lending) GetTriegc() *prque.Prque {
func (l *Lending) GetTriegc() *prque.Prque[int64, common.Hash] {
return l.Triegc
}

Expand Down
22 changes: 11 additions & 11 deletions XDCxlending/lendingstate/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (ls *LendingStateDB) DumpInvestingTrie(orderBook common.Hash) (map[*big.Int
it := trie.NewIterator(exhangeObject.getInvestingTrie(ls.db).NodeIterator(nil))
for it.Next() {
interestHash := common.BytesToHash(it.Key)
if common.EmptyHash(interestHash) {
if interestHash.IsZero() {
continue
}
interest := new(big.Int).SetBytes(interestHash.Bytes())
Expand Down Expand Up @@ -91,7 +91,7 @@ func (ls *LendingStateDB) DumpBorrowingTrie(orderBook common.Hash) (map[*big.Int
it := trie.NewIterator(exhangeObject.getBorrowingTrie(ls.db).NodeIterator(nil))
for it.Next() {
interestHash := common.BytesToHash(it.Key)
if common.EmptyHash(interestHash) {
if interestHash.IsZero() {
continue
}
interest := new(big.Int).SetBytes(interestHash.Bytes())
Expand Down Expand Up @@ -134,7 +134,7 @@ func (ls *LendingStateDB) GetInvestings(orderBook common.Hash) (map[*big.Int]*bi
it := trie.NewIterator(exhangeObject.getInvestingTrie(ls.db).NodeIterator(nil))
for it.Next() {
interestHash := common.BytesToHash(it.Key)
if common.EmptyHash(interestHash) {
if interestHash.IsZero() {
continue
}
interest := new(big.Int).SetBytes(interestHash.Bytes())
Expand Down Expand Up @@ -177,7 +177,7 @@ func (ls *LendingStateDB) GetBorrowings(orderBook common.Hash) (map[*big.Int]*bi
it := trie.NewIterator(exhangeObject.getBorrowingTrie(ls.db).NodeIterator(nil))
for it.Next() {
interestHash := common.BytesToHash(it.Key)
if common.EmptyHash(interestHash) {
if interestHash.IsZero() {
continue
}
interest := new(big.Int).SetBytes(interestHash.Bytes())
Expand Down Expand Up @@ -216,7 +216,7 @@ func (il *itemListState) DumpItemList(db Database) DumpOrderList {
orderListIt := trie.NewIterator(il.getTrie(db).NodeIterator(nil))
for orderListIt.Next() {
keyHash := common.BytesToHash(orderListIt.Key)
if common.EmptyHash(keyHash) {
if keyHash.IsZero() {
continue
}
if _, exist := il.cachedStorage[keyHash]; exist {
Expand All @@ -227,7 +227,7 @@ func (il *itemListState) DumpItemList(db Database) DumpOrderList {
}
}
for key, value := range il.cachedStorage {
if !common.EmptyHash(value) {
if !value.IsZero() {
mapResult.Orders[new(big.Int).SetBytes(key.Bytes())] = new(big.Int).SetBytes(value.Bytes())
}
}
Expand Down Expand Up @@ -265,7 +265,7 @@ func (lts *liquidationTimeState) DumpItemList(db Database) DumpOrderList {
orderListIt := trie.NewIterator(lts.getTrie(db).NodeIterator(nil))
for orderListIt.Next() {
keyHash := common.BytesToHash(orderListIt.Key)
if common.EmptyHash(keyHash) {
if keyHash.IsZero() {
continue
}
if _, exist := lts.cachedStorage[keyHash]; exist {
Expand All @@ -276,7 +276,7 @@ func (lts *liquidationTimeState) DumpItemList(db Database) DumpOrderList {
}
}
for key, value := range lts.cachedStorage {
if !common.EmptyHash(value) {
if !value.IsZero() {
mapResult.Orders[new(big.Int).SetBytes(key.Bytes())] = new(big.Int).SetBytes(value.Bytes())
}
}
Expand All @@ -303,7 +303,7 @@ func (ls *LendingStateDB) DumpLiquidationTimeTrie(orderBook common.Hash) (map[*b
it := trie.NewIterator(exhangeObject.getLiquidationTimeTrie(ls.db).NodeIterator(nil))
for it.Next() {
unixTimeHash := common.BytesToHash(it.Key)
if common.EmptyHash(unixTimeHash) {
if unixTimeHash.IsZero() {
continue
}
unixTime := new(big.Int).SetBytes(unixTimeHash.Bytes())
Expand Down Expand Up @@ -346,7 +346,7 @@ func (ls *LendingStateDB) DumpLendingOrderTrie(orderBook common.Hash) (map[*big.
it := trie.NewIterator(exhangeObject.getLendingItemTrie(ls.db).NodeIterator(nil))
for it.Next() {
orderIdHash := common.BytesToHash(it.Key)
if common.EmptyHash(orderIdHash) {
if orderIdHash.IsZero() {
continue
}
orderId := new(big.Int).SetBytes(orderIdHash.Bytes())
Expand Down Expand Up @@ -386,7 +386,7 @@ func (ls *LendingStateDB) DumpLendingTradeTrie(orderBook common.Hash) (map[*big.
it := trie.NewIterator(exhangeObject.getLendingTradeTrie(ls.db).NodeIterator(nil))
for it.Next() {
tradeIdHash := common.BytesToHash(it.Key)
if common.EmptyHash(tradeIdHash) {
if tradeIdHash.IsZero() {
continue
}
tradeId := new(big.Int).SetBytes(tradeIdHash.Bytes())
Expand Down
10 changes: 5 additions & 5 deletions XDCxlending/lendingstate/state_lendingbook.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,19 @@ func (s *lendingExchangeState) empty() bool {
if s.data.TradeNonce != 0 {
return false
}
if !common.EmptyHash(s.data.InvestingRoot) {
if !s.data.InvestingRoot.IsZero() {
return false
}
if !common.EmptyHash(s.data.BorrowingRoot) {
if !s.data.BorrowingRoot.IsZero() {
return false
}
if !common.EmptyHash(s.data.LendingItemRoot) {
if !s.data.LendingItemRoot.IsZero() {
return false
}
if !common.EmptyHash(s.data.LendingTradeRoot) {
if !s.data.LendingTradeRoot.IsZero() {
return false
}
if !common.EmptyHash(s.data.LiquidationTimeRoot) {
if !s.data.LiquidationTimeRoot.IsZero() {
return false
}
return true
Expand Down
2 changes: 1 addition & 1 deletion XDCxlending/lendingstate/state_liquidationtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (lt *liquidationTimeState) getAllTradeIds(db Database) []common.Hash {
return tradeIds
}
for id, value := range lt.cachedStorage {
if !common.EmptyHash(value) {
if !value.IsZero() {
tradeIds = append(tradeIds, id)
}
}
Expand Down
4 changes: 2 additions & 2 deletions XDCxlending/lendingstate/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ func (ls *LendingStateDB) GetBestInvestingRate(orderBook common.Hash) (*big.Int,
stateObject := ls.getLendingExchange(orderBook)
if stateObject != nil {
investingHash := stateObject.getBestInvestingInterest(ls.db)
if common.EmptyHash(investingHash) {
if investingHash.IsZero() {
return Zero, Zero
}
orderList := stateObject.getInvestingOrderList(ls.db, investingHash)
Expand All @@ -360,7 +360,7 @@ func (ls *LendingStateDB) GetBestBorrowRate(orderBook common.Hash) (*big.Int, *b
stateObject := ls.getLendingExchange(orderBook)
if stateObject != nil {
priceHash := stateObject.getBestBorrowingInterest(ls.db)
if common.EmptyHash(priceHash) {
if priceHash.IsZero() {
return Zero, Zero
}
orderList := stateObject.getBorrowingOrderList(ls.db, priceHash)
Expand Down
2 changes: 1 addition & 1 deletion XDCxlending/order_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ func DoSettleBalance(coinbase common.Address, takerOrder, makerOrder *lendingsta
// masternodes only charge borrower relayer fee
matchingFee = new(big.Int).Add(matchingFee, common.RelayerLendingFee)

if common.EmptyHash(takerExOwner.Hash()) || common.EmptyHash(makerExOwner.Hash()) {
if takerExOwner.Hash().IsZero() || makerExOwner.Hash().IsZero() {
return fmt.Errorf("empty echange owner: taker: %v , maker : %v", takerExOwner, makerExOwner)
}
mapBalances := map[common.Address]map[common.Address]*big.Int{}
Expand Down
Loading
Loading