@@ -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
2522const (
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-
7957func 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
9573func 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-
13094func (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-
157106func (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 {}
0 commit comments