Fix xdcx infinite recursive calls (#404)

* fix: Make the unused methods in leveldb.go in XDCxDAO to panic or return error if called

* fix: apply the same fix in mongodb of the XDCxDAO as well
This commit is contained in:
Banana-J 2024-01-28 16:57:58 +11:00 committed by GitHub
parent 2504961a33
commit a3c392cdde
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 9 deletions

View file

@ -4,9 +4,10 @@ import (
"bytes"
"encoding/hex"
"errors"
"sync"
"github.com/XinFinOrg/XDPoSChain/common"
"github.com/XinFinOrg/XDPoSChain/core/rawdb"
"sync"
"github.com/XinFinOrg/XDPoSChain/ethdb"
"github.com/XinFinOrg/XDPoSChain/log"
@ -171,13 +172,13 @@ func (db *BatchDatabase) Sync() error {
}
func (db *BatchDatabase) NewIterator(prefix []byte, start []byte) ethdb.Iterator {
return db.NewIterator(prefix, start)
panic("NewIterator from XDCxDAO leveldb is not supported")
}
func (db *BatchDatabase) Stat(property string) (string, error) {
return db.Stat(property)
return "", errNotSupported
}
func (db *BatchDatabase) Compact(start []byte, limit []byte) error {
return db.Compact(start, limit)
return errNotSupported
}

View file

@ -4,6 +4,9 @@ import (
"bytes"
"encoding/hex"
"fmt"
"strings"
"time"
"github.com/XinFinOrg/XDPoSChain/XDCx/tradingstate"
"github.com/XinFinOrg/XDPoSChain/XDCxlending/lendingstate"
"github.com/XinFinOrg/XDPoSChain/common"
@ -12,8 +15,6 @@ import (
"github.com/globalsign/mgo"
"github.com/globalsign/mgo/bson"
lru "github.com/hashicorp/golang-lru"
"strings"
"time"
)
const (
@ -873,15 +874,15 @@ func (db *MongoDatabase) Sync() error {
}
func (db *MongoDatabase) NewIterator(prefix []byte, start []byte) ethdb.Iterator {
return db.NewIterator(prefix, start)
panic("NewIterator from XDCxDAO mongodb is not supported")
}
func (db *MongoDatabase) Stat(property string) (string, error) {
return db.Stat(property)
return "", errNotSupported
}
func (db *MongoDatabase) Compact(start []byte, limit []byte) error {
return db.Compact(start, limit)
return errNotSupported
}
func (db *MongoDatabase) NewBatch() ethdb.Batch {