Skip to content

Commit 13ed19b

Browse files
authored
all: remove XDCx and XDCxlending public API, close XFN-74 XFN-134 (#1675)
* internal: remove XDCx public API * XDCx, XDCxlending: remove api * ethclient: remove SendOrderTransaction and SendLendingTransaction * XDCx, XDCxlending: remove unused variables and function * eth, internal/ethapi: remove function `OrderStats()`
1 parent 8ca3572 commit 13ed19b

File tree

13 files changed

+14
-1810
lines changed

13 files changed

+14
-1810
lines changed

XDCx/XDCx.go

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,9 @@ import (
1717
"github.com/XinFinOrg/XDPoSChain/core/types"
1818
"github.com/XinFinOrg/XDPoSChain/log"
1919
"github.com/XinFinOrg/XDPoSChain/node"
20-
"github.com/XinFinOrg/XDPoSChain/p2p"
21-
"github.com/XinFinOrg/XDPoSChain/rpc"
22-
"golang.org/x/sync/syncmap"
2320
)
2421

2522
const (
26-
ProtocolName = "XDCx"
27-
ProtocolVersion = uint64(1)
28-
ProtocolVersionStr = "1.0"
29-
overflowIdx // Indicator of message queue overflow
3023
defaultCacheLimit = 1024
3124
MaximumTxMatchSize = 1000
3225
)
@@ -56,26 +49,11 @@ type XDCX struct {
5649
Triegc *prque.Prque[int64, common.Hash] // Priority queue mapping block numbers to tries to gc
5750
StateCache tradingstate.Database // State database to reuse between imports (contains state cache) *XDCx_state.TradingStateDB
5851

59-
orderNonce map[common.Address]*big.Int
60-
6152
sdkNode bool
62-
settings syncmap.Map // holds configuration settings that can be dynamically changed
6353
tokenDecimalCache *lru.Cache[common.Address, *big.Int]
6454
orderCache *lru.Cache[common.Hash, map[common.Hash]tradingstate.OrderHistoryItem]
6555
}
6656

67-
func (XDCx *XDCX) Protocols() []p2p.Protocol {
68-
return []p2p.Protocol{}
69-
}
70-
71-
func (XDCx *XDCX) Start() error {
72-
return nil
73-
}
74-
75-
func (XDCx *XDCX) Stop() error {
76-
return nil
77-
}
78-
7957
func NewLDBEngine(cfg *Config) *XDCxDAO.BatchDatabase {
8058
datadir := cfg.DataDir
8159
batchDB := XDCxDAO.NewBatchDatabaseWithEncode(datadir, 0)
@@ -94,7 +72,6 @@ func NewMongoDBEngine(cfg *Config) *XDCxDAO.MongoDatabase {
9472

9573
func New(stack *node.Node, cfg *Config) *XDCX {
9674
XDCX := &XDCX{
97-
orderNonce: make(map[common.Address]*big.Int),
9875
Triegc: prque.New[int64, common.Hash](nil),
9976
tokenDecimalCache: lru.NewCache[common.Address, *big.Int](defaultCacheLimit),
10077
orderCache: lru.NewCache[common.Hash, map[common.Hash]tradingstate.OrderHistoryItem](tradingstate.OrderCacheLimit),
@@ -110,23 +87,10 @@ func New(stack *node.Node, cfg *Config) *XDCX {
11087
}
11188

11289
XDCX.StateCache = tradingstate.NewDatabase(XDCX.db)
113-
XDCX.settings.Store(overflowIdx, false)
11490

115-
stack.RegisterAPIs(XDCX.APIs())
116-
stack.RegisterProtocols(XDCX.Protocols())
117-
stack.RegisterLifecycle(XDCX)
11891
return XDCX
11992
}
12093

121-
// Overflow returns an indication if the message queue is full.
122-
func (XDCx *XDCX) Overflow() bool {
123-
val, ok := XDCx.settings.Load(overflowIdx)
124-
if !ok {
125-
log.Warn("[XDCx-Overflow] fail to load overflow index")
126-
}
127-
return val.(bool)
128-
}
129-
13094
func (XDCx *XDCX) IsSDKNode() bool {
13195
return XDCx.sdkNode
13296
}
@@ -139,21 +103,6 @@ func (XDCx *XDCX) GetMongoDB() XDCxDAO.XDCXDAO {
139103
return XDCx.mongodb
140104
}
141105

142-
// APIs returns the RPC descriptors the XDCX implementation offers
143-
func (XDCx *XDCX) APIs() []rpc.API {
144-
return []rpc.API{
145-
{
146-
Namespace: ProtocolName,
147-
Service: NewPublicXDCXAPI(XDCx),
148-
},
149-
}
150-
}
151-
152-
// Version returns the XDCX sub-protocols version number.
153-
func (XDCx *XDCX) Version() uint64 {
154-
return ProtocolVersion
155-
}
156-
157106
func (XDCx *XDCX) ProcessOrderPending(header *types.Header, coinbase common.Address, chain consensus.ChainContext, pending map[common.Address]types.OrderTransactions, statedb *state.StateDB, XDCXstatedb *tradingstate.TradingStateDB) ([]tradingstate.TxDataMatch, map[common.Hash]tradingstate.MatchingResult) {
158107
txMatches := []tradingstate.TxDataMatch{}
159108
matchingResults := map[common.Hash]tradingstate.MatchingResult{}

XDCx/api.go

Lines changed: 0 additions & 42 deletions
This file was deleted.

XDCxlending/XDCxlending.go

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,10 @@ import (
2020
"github.com/XinFinOrg/XDPoSChain/core/types"
2121
"github.com/XinFinOrg/XDPoSChain/log"
2222
"github.com/XinFinOrg/XDPoSChain/node"
23-
"github.com/XinFinOrg/XDPoSChain/p2p"
24-
"github.com/XinFinOrg/XDPoSChain/rpc"
2523
)
2624

2725
const (
28-
ProtocolName = "XDCxlending"
29-
ProtocolVersion = uint64(1)
30-
ProtocolVersionStr = "1.0"
31-
defaultCacheLimit = 1024
26+
defaultCacheLimit = 1024
3227
)
3328

3429
var (
@@ -40,40 +35,20 @@ type Lending struct {
4035
Triegc *prque.Prque[int64, common.Hash] // Priority queue mapping block numbers to tries to gc
4136
StateCache lendingstate.Database // State database to reuse between imports (contains state cache) *lendingstate.TradingStateDB
4237

43-
orderNonce map[common.Address]*big.Int
44-
4538
XDCx *XDCx.XDCX
4639
lendingItemHistory *lru.Cache[common.Hash, map[common.Hash]lendingstate.LendingItemHistoryItem]
4740
lendingTradeHistory *lru.Cache[common.Hash, map[common.Hash]lendingstate.LendingTradeHistoryItem]
4841
}
4942

50-
func (l *Lending) Protocols() []p2p.Protocol {
51-
return []p2p.Protocol{}
52-
}
53-
54-
func (l *Lending) Start() error {
55-
return nil
56-
}
57-
58-
func (l *Lending) Stop() error {
59-
return nil
60-
}
61-
6243
func New(stack *node.Node, XDCx *XDCx.XDCX) *Lending {
6344
lending := &Lending{
64-
orderNonce: make(map[common.Address]*big.Int),
6545
Triegc: prque.New[int64, common.Hash](nil),
6646
lendingItemHistory: lru.NewCache[common.Hash, map[common.Hash]lendingstate.LendingItemHistoryItem](defaultCacheLimit),
6747
lendingTradeHistory: lru.NewCache[common.Hash, map[common.Hash]lendingstate.LendingTradeHistoryItem](defaultCacheLimit),
6848
}
6949
lending.StateCache = lendingstate.NewDatabase(XDCx.GetLevelDB())
7050
lending.XDCx = XDCx
7151

72-
// Register the backend on the node
73-
stack.RegisterAPIs(lending.APIs())
74-
stack.RegisterProtocols(lending.Protocols())
75-
stack.RegisterLifecycle(lending)
76-
7752
return lending
7853
}
7954

@@ -85,21 +60,6 @@ func (l *Lending) GetMongoDB() XDCxDAO.XDCXDAO {
8560
return l.XDCx.GetMongoDB()
8661
}
8762

88-
// APIs returns the RPC descriptors the Lending implementation offers
89-
func (l *Lending) APIs() []rpc.API {
90-
return []rpc.API{
91-
{
92-
Namespace: ProtocolName,
93-
Service: NewPublicXDCXLendingAPI(l),
94-
},
95-
}
96-
}
97-
98-
// Version returns the Lending sub-protocols version number.
99-
func (l *Lending) Version() uint64 {
100-
return ProtocolVersion
101-
}
102-
10363
func (l *Lending) ProcessOrderPending(header *types.Header, coinbase common.Address, chain consensus.ChainContext, pending map[common.Address]types.LendingTransactions, statedb *state.StateDB, lendingStatedb *lendingstate.LendingStateDB, tradingStateDb *tradingstate.TradingStateDB) ([]*lendingstate.LendingItem, map[common.Hash]lendingstate.MatchingResult) {
10464
lendingItems := []*lendingstate.LendingItem{}
10565
matchingResults := map[common.Hash]lendingstate.MatchingResult{}

XDCxlending/api.go

Lines changed: 0 additions & 37 deletions
This file was deleted.

cmd/XDC/consolecmd_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
)
3131

3232
const (
33-
ipcAPIs = "XDCx:1.0 XDCxlending:1.0 XDPoS:1.0 admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 rpc:1.0 txpool:1.0 web3:1.0"
33+
ipcAPIs = "XDPoS:1.0 admin:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 rpc:1.0 txpool:1.0 web3:1.0"
3434
httpAPIs = "eth:1.0 net:1.0 rpc:1.0 web3:1.0"
3535
)
3636

0 commit comments

Comments
 (0)