mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-19 21:31:37 +00:00
XDCx: remove unused functions and variables (#1530)
Co-authored-by: wit <wit765765346@gmail>
This commit is contained in:
parent
a663ea311c
commit
607fa3cc90
7 changed files with 2 additions and 69 deletions
|
|
@ -38,7 +38,6 @@ import (
|
|||
// XDCXTrie is not safe for concurrent use.
|
||||
type XDCXTrie struct {
|
||||
trie trie.Trie
|
||||
hashKeyBuf [common.HashLength]byte
|
||||
secKeyCache map[string][]byte
|
||||
secKeyCacheOwner *XDCXTrie // Pointer to self, replace the key cache on mismatch
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ package tradingstate
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/XinFinOrg/XDPoSChain/common"
|
||||
"github.com/XinFinOrg/XDPoSChain/ethdb"
|
||||
|
|
@ -28,12 +27,6 @@ import (
|
|||
// Trie cache generation limit after which to evic trie nodes from memory.
|
||||
var MaxTrieCacheGen = uint16(120)
|
||||
|
||||
const (
|
||||
// Number of past tries to keep. This value is chosen such that
|
||||
// reasonable chain reorg depths will hit an existing trie.
|
||||
maxPastTries = 12
|
||||
)
|
||||
|
||||
// Database wraps access to tries and contract code.
|
||||
type Database interface {
|
||||
// OpenTrie opens the main account trie.
|
||||
|
|
@ -81,9 +74,7 @@ func NewDatabase(db ethdb.Database) Database {
|
|||
}
|
||||
|
||||
type cachingDB struct {
|
||||
db *trie.Database
|
||||
mu sync.Mutex
|
||||
pastTries []*XDCXTrie
|
||||
db *trie.Database
|
||||
}
|
||||
|
||||
// OpenTrie opens the main account trie.
|
||||
|
|
@ -91,17 +82,6 @@ func (db *cachingDB) OpenTrie(root common.Hash) (Trie, error) {
|
|||
return NewXDCXTrie(root, db.db)
|
||||
}
|
||||
|
||||
func (db *cachingDB) pushTrie(t *XDCXTrie) {
|
||||
db.mu.Lock()
|
||||
defer db.mu.Unlock()
|
||||
if len(db.pastTries) >= maxPastTries {
|
||||
copy(db.pastTries, db.pastTries[1:])
|
||||
db.pastTries[len(db.pastTries)-1] = t
|
||||
} else {
|
||||
db.pastTries = append(db.pastTries, t)
|
||||
}
|
||||
}
|
||||
|
||||
// OpenStorageTrie opens the storage trie of an account.
|
||||
func (db *cachingDB) OpenStorageTrie(addrHash, root common.Hash) (Trie, error) {
|
||||
return NewXDCXTrie(root, db.db)
|
||||
|
|
|
|||
|
|
@ -279,13 +279,6 @@ func (o *OrderItem) verifyOrderSide() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (o *OrderItem) encodedSide() *big.Int {
|
||||
if o.Side == Bid {
|
||||
return big.NewInt(0)
|
||||
}
|
||||
return big.NewInt(1)
|
||||
}
|
||||
|
||||
// verifyPrice make sure price is a positive number
|
||||
func (o *OrderItem) verifyPrice() error {
|
||||
if o.Price == nil || o.Price.Sign() <= 0 {
|
||||
|
|
|
|||
|
|
@ -2,9 +2,7 @@ package XDCxDAO
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"sync"
|
||||
|
||||
"github.com/XinFinOrg/XDPoSChain/common"
|
||||
"github.com/XinFinOrg/XDPoSChain/core/rawdb"
|
||||
|
|
@ -19,7 +17,6 @@ type BatchItem struct {
|
|||
type BatchDatabase struct {
|
||||
db ethdb.Database
|
||||
emptyKey []byte
|
||||
lock sync.RWMutex
|
||||
cacheLimit int
|
||||
Debug bool
|
||||
}
|
||||
|
|
@ -55,10 +52,6 @@ func (db *BatchDatabase) IsEmptyKey(key []byte) bool {
|
|||
return len(key) == 0 || bytes.Equal(key, db.emptyKey)
|
||||
}
|
||||
|
||||
func (db *BatchDatabase) getCacheKey(key []byte) string {
|
||||
return hex.EncodeToString(key)
|
||||
}
|
||||
|
||||
func (db *BatchDatabase) HasObject(hash common.Hash, val interface{}) (bool, error) {
|
||||
// for mongodb only
|
||||
return false, nil
|
||||
|
|
|
|||
|
|
@ -886,19 +886,8 @@ func (db *MongoDatabase) NewBatchWithSize(size int) ethdb.Batch {
|
|||
return nil
|
||||
}
|
||||
|
||||
type keyvalue struct {
|
||||
key []byte
|
||||
value []byte
|
||||
}
|
||||
type Batch struct {
|
||||
db *MongoDatabase
|
||||
collection string
|
||||
b []keyvalue
|
||||
size int
|
||||
}
|
||||
|
||||
func (b *Batch) SetCollection(collection string) {
|
||||
// for levelDB only
|
||||
}
|
||||
|
||||
func (b *Batch) Put(key, value []byte) error {
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ import (
|
|||
// XDCXTrie is not safe for concurrent use.
|
||||
type XDCXTrie struct {
|
||||
trie trie.Trie
|
||||
hashKeyBuf [common.HashLength]byte
|
||||
secKeyCache map[string][]byte
|
||||
secKeyCacheOwner *XDCXTrie // Pointer to self, replace the key cache on mismatch
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ package lendingstate
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/XinFinOrg/XDPoSChain/common"
|
||||
"github.com/XinFinOrg/XDPoSChain/ethdb"
|
||||
|
|
@ -28,12 +27,6 @@ import (
|
|||
// Trie cache generation limit after which to evic trie nodes from memory.
|
||||
var MaxTrieCacheGen = uint16(120)
|
||||
|
||||
const (
|
||||
// Number of past tries to keep. This value is chosen such that
|
||||
// reasonable chain reorg depths will hit an existing trie.
|
||||
maxPastTries = 12
|
||||
)
|
||||
|
||||
// Database wraps access to tries and contract code.
|
||||
type Database interface {
|
||||
// OpenTrie opens the main account trie.
|
||||
|
|
@ -81,9 +74,7 @@ func NewDatabase(db ethdb.Database) Database {
|
|||
}
|
||||
|
||||
type cachingDB struct {
|
||||
db *trie.Database
|
||||
mu sync.Mutex
|
||||
pastTries []*XDCXTrie
|
||||
db *trie.Database
|
||||
}
|
||||
|
||||
// OpenTrie opens the main account trie.
|
||||
|
|
@ -91,17 +82,6 @@ func (db *cachingDB) OpenTrie(root common.Hash) (Trie, error) {
|
|||
return NewXDCXTrie(root, db.db)
|
||||
}
|
||||
|
||||
func (db *cachingDB) pushTrie(t *XDCXTrie) {
|
||||
db.mu.Lock()
|
||||
defer db.mu.Unlock()
|
||||
if len(db.pastTries) >= maxPastTries {
|
||||
copy(db.pastTries, db.pastTries[1:])
|
||||
db.pastTries[len(db.pastTries)-1] = t
|
||||
} else {
|
||||
db.pastTries = append(db.pastTries, t)
|
||||
}
|
||||
}
|
||||
|
||||
// OpenStorageTrie opens the storage trie of an account.
|
||||
func (db *cachingDB) OpenStorageTrie(addrHash, root common.Hash) (Trie, error) {
|
||||
return NewXDCXTrie(root, db.db)
|
||||
|
|
|
|||
Loading…
Reference in a new issue