@@ -37,24 +37,25 @@ Value dxGetTransactionList(const Array & params, bool fHelp)
3737 throw runtime_error (" dxGetTransactionList\n List transactions." );
3838 }
3939
40- XBridgeExchange & e = XBridgeExchange::instance ();
41- if (!e.isEnabled ())
42- throw runtime_error (" Not an exchange node." );
43-
4440 Array arr;
4541
42+ boost::mutex::scoped_lock l (XBridgeApp::m_txLocker);
43+
4644 // pending tx
4745 {
48- std::list<XBridgeTransactionPtr > trlist = e. pendingTransactions () ;
49- for (XBridgeTransactionPtr & tr : trlist)
46+ std::map<uint256, XBridgeTransactionDescrPtr > trlist = XBridgeApp::m_pendingTransactions ;
47+ for (const auto & trEntry : trlist)
5048 {
5149 Object jtr;
52- jtr.push_back (Pair (" id" , tr->id ().GetHex ()));
53- jtr.push_back (Pair (" from" , tr->a_currency ()));
54- double fromAmount = static_cast <double >(tr->a_amount ()) / XBridgeTransactionDescr::COIN;
50+ const auto tr = trEntry.second ;
51+ jtr.push_back (Pair (" id" , tr->id .GetHex ()));
52+ jtr.push_back (Pair (" from" , tr->fromCurrency ));
53+ jtr.push_back (Pair (" from address" , tr->from ));
54+ double fromAmount = static_cast <double >(tr->fromAmount ) / XBridgeTransactionDescr::COIN;
5555 jtr.push_back (Pair (" fromAmount" , boost::lexical_cast<std::string>(fromAmount)));
56- jtr.push_back (Pair (" to" , tr->b_currency ()));
57- double toAmount = static_cast <double >(tr->b_amount ()) / XBridgeTransactionDescr::COIN;
56+ jtr.push_back (Pair (" to" , tr->toCurrency ));
57+ jtr.push_back (Pair (" to address" , tr->to ));
58+ double toAmount = static_cast <double >(tr->toAmount ) / XBridgeTransactionDescr::COIN;
5859 jtr.push_back (Pair (" toAmount" , boost::lexical_cast<std::string>(toAmount)));
5960 jtr.push_back (Pair (" state" , tr->strState ()));
6061
@@ -64,16 +65,19 @@ Value dxGetTransactionList(const Array & params, bool fHelp)
6465
6566 // active tx
6667 {
67- std::list<XBridgeTransactionPtr > trlist = e. transactions () ;
68- for (XBridgeTransactionPtr & tr : trlist)
68+ std::map<uint256, XBridgeTransactionDescrPtr > trlist = XBridgeApp::m_transactions ;
69+ for (const auto & trEntry : trlist)
6970 {
7071 Object jtr;
71- jtr.push_back (Pair (" id" , tr->id ().GetHex ()));
72- jtr.push_back (Pair (" from" , tr->a_currency ()));
73- double fromAmount = static_cast <double >(tr->a_amount ()) / XBridgeTransactionDescr::COIN;
72+ const auto tr = trEntry.second ;
73+ jtr.push_back (Pair (" id" , tr->id .GetHex ()));
74+ jtr.push_back (Pair (" from" , tr->fromCurrency ));
75+ jtr.push_back (Pair (" from address" , tr->from ));
76+ double fromAmount = static_cast <double >(tr->fromAmount ) / XBridgeTransactionDescr::COIN;
7477 jtr.push_back (Pair (" fromAmount" , boost::lexical_cast<std::string>(fromAmount)));
75- jtr.push_back (Pair (" to" , tr->b_currency ()));
76- double toAmount = static_cast <double >(tr->b_amount ()) / XBridgeTransactionDescr::COIN;
78+ jtr.push_back (Pair (" to" , tr->toCurrency ));
79+ jtr.push_back (Pair (" to address" , tr->to ));
80+ double toAmount = static_cast <double >(tr->toAmount ) / XBridgeTransactionDescr::COIN;
7781 jtr.push_back (Pair (" toAmount" , boost::lexical_cast<std::string>(toAmount)));
7882 jtr.push_back (Pair (" state" , tr->strState ()));
7983
@@ -94,25 +98,24 @@ Value dxGetTransactionsHistoryList(const Array & params, bool fHelp)
9498 throw runtime_error (" dxGetTransactionsHistoryList\n Historic list transactions." );
9599 }
96100
97- XBridgeExchange & e = XBridgeExchange::instance ();
98- if (!e.isEnabled ())
99- throw runtime_error (" Not an exchange node." );
100-
101101 Array arr;
102102
103+ boost::mutex::scoped_lock l (XBridgeApp::m_txLocker);
104+
103105 {
104- std::list<XBridgeTransactionPtr > trlist = e. transactionsHistory () ;
105- for (XBridgeTransactionPtr & tr : trlist)
106+ std::map<uint256, XBridgeTransactionDescrPtr > trlist = XBridgeApp::m_historicTransactions ;
107+ for (const auto & trEntry : trlist)
106108 {
107109 Object jtr;
108- jtr.push_back (Pair (" id" , tr->id ().GetHex ()));
109- jtr.push_back (Pair (" from" , tr->a_currency ()));
110- jtr.push_back (Pair (" from address" , tr->a_address ()));
111- double fromAmount = static_cast <double >(tr->a_amount ()) / XBridgeTransactionDescr::COIN;
110+ const auto tr = trEntry.second ;
111+ jtr.push_back (Pair (" id" , tr->id .GetHex ()));
112+ jtr.push_back (Pair (" from" , tr->fromCurrency ));
113+ jtr.push_back (Pair (" from address" , tr->from ));
114+ double fromAmount = static_cast <double >(tr->fromAmount ) / XBridgeTransactionDescr::COIN;
112115 jtr.push_back (Pair (" fromAmount" , boost::lexical_cast<std::string>(fromAmount)));
113- jtr.push_back (Pair (" to" , tr->b_currency () ));
114- jtr.push_back (Pair (" to address" , tr->a_destination () ));
115- double toAmount = static_cast <double >(tr->b_amount () ) / XBridgeTransactionDescr::COIN;
116+ jtr.push_back (Pair (" to" , tr->toCurrency ));
117+ jtr.push_back (Pair (" to address" , tr->to ));
118+ double toAmount = static_cast <double >(tr->toAmount ) / XBridgeTransactionDescr::COIN;
116119 jtr.push_back (Pair (" toAmount" , boost::lexical_cast<std::string>(toAmount)));
117120 jtr.push_back (Pair (" state" , tr->strState ()));
118121
@@ -133,27 +136,27 @@ Value dxGetTransactionInfo(const Array & params, bool fHelp)
133136 throw runtime_error (" dxGetTransactionInfo\n Transaction info." );
134137 }
135138
136- XBridgeExchange & e = XBridgeExchange::instance ();
137- if (!e.isEnabled ())
138- throw runtime_error (" Not an exchange node." );
139-
140139 std::string id = params[0 ].get_str ();
140+
141141 Array arr;
142142
143+ boost::mutex::scoped_lock l (XBridgeApp::m_txLocker);
144+
143145 // pending tx
144146 {
145- std::list<XBridgeTransactionPtr > trlist = e. pendingTransactions () ;
146- for (XBridgeTransactionPtr & tr : trlist)
147+ std::map<uint256, XBridgeTransactionDescrPtr > trlist = XBridgeApp::m_pendingTransactions ;
148+ for (const auto & trEntry : trlist)
147149 {
148150 Object jtr;
149- jtr.push_back (Pair (" id" , tr->id ().GetHex ()));
150- jtr.push_back (Pair (" from" , tr->a_currency ()));
151- jtr.push_back (Pair (" from address" , tr->a_address ()));
152- double fromAmount = static_cast <double >(tr->a_amount ()) / XBridgeTransactionDescr::COIN;
151+ const auto tr = trEntry.second ;
152+ jtr.push_back (Pair (" id" , tr->id .GetHex ()));
153+ jtr.push_back (Pair (" from" , tr->fromCurrency ));
154+ jtr.push_back (Pair (" from address" , tr->from ));
155+ double fromAmount = static_cast <double >(tr->fromAmount ) / XBridgeTransactionDescr::COIN;
153156 jtr.push_back (Pair (" fromAmount" , boost::lexical_cast<std::string>(fromAmount)));
154- jtr.push_back (Pair (" to" , tr->b_currency () ));
155- jtr.push_back (Pair (" to address" , tr->a_destination () ));
156- double toAmount = static_cast <double >(tr->b_amount () ) / XBridgeTransactionDescr::COIN;
157+ jtr.push_back (Pair (" to" , tr->toCurrency ));
158+ jtr.push_back (Pair (" to address" , tr->to ));
159+ double toAmount = static_cast <double >(tr->toAmount ) / XBridgeTransactionDescr::COIN;
157160 jtr.push_back (Pair (" toAmount" , boost::lexical_cast<std::string>(toAmount)));
158161 jtr.push_back (Pair (" state" , tr->strState ()));
159162
@@ -163,18 +166,19 @@ Value dxGetTransactionInfo(const Array & params, bool fHelp)
163166
164167 // active tx
165168 {
166- std::list<XBridgeTransactionPtr > trlist = e. transactions () ;
167- for (XBridgeTransactionPtr & tr : trlist)
169+ std::map<uint256, XBridgeTransactionDescrPtr > trlist = XBridgeApp::m_transactions ;
170+ for (const auto & trEntry : trlist)
168171 {
169172 Object jtr;
170- jtr.push_back (Pair (" id" , tr->id ().GetHex ()));
171- jtr.push_back (Pair (" from" , tr->a_currency ()));
172- jtr.push_back (Pair (" from address" , tr->a_address ()));
173- double fromAmount = static_cast <double >(tr->a_amount ()) / XBridgeTransactionDescr::COIN;
173+ const auto tr = trEntry.second ;
174+ jtr.push_back (Pair (" id" , tr->id .GetHex ()));
175+ jtr.push_back (Pair (" from" , tr->fromCurrency ));
176+ jtr.push_back (Pair (" from address" , tr->from ));
177+ double fromAmount = static_cast <double >(tr->fromAmount ) / XBridgeTransactionDescr::COIN;
174178 jtr.push_back (Pair (" fromAmount" , boost::lexical_cast<std::string>(fromAmount)));
175- jtr.push_back (Pair (" to" , tr->b_currency () ));
176- jtr.push_back (Pair (" to address" , tr->a_destination () ));
177- double toAmount = static_cast <double >(tr->b_amount () ) / XBridgeTransactionDescr::COIN;
179+ jtr.push_back (Pair (" to" , tr->toCurrency ));
180+ jtr.push_back (Pair (" to address" , tr->to ));
181+ double toAmount = static_cast <double >(tr->toAmount ) / XBridgeTransactionDescr::COIN;
178182 jtr.push_back (Pair (" toAmount" , boost::lexical_cast<std::string>(toAmount)));
179183 jtr.push_back (Pair (" state" , tr->strState ()));
180184
@@ -184,18 +188,19 @@ Value dxGetTransactionInfo(const Array & params, bool fHelp)
184188
185189 // historic tx
186190 {
187- std::list<XBridgeTransactionPtr > trlist = e. transactionsHistory () ;
188- for (XBridgeTransactionPtr & tr : trlist)
191+ std::map<uint256, XBridgeTransactionDescrPtr > trlist = XBridgeApp::m_historicTransactions ;
192+ for (const auto & trEntry : trlist)
189193 {
190194 Object jtr;
191- jtr.push_back (Pair (" id" , tr->id ().GetHex ()));
192- jtr.push_back (Pair (" from" , tr->a_currency ()));
193- jtr.push_back (Pair (" from address" , tr->a_address ()));
194- double fromAmount = static_cast <double >(tr->a_amount ()) / XBridgeTransactionDescr::COIN;
195+ const auto tr = trEntry.second ;
196+ jtr.push_back (Pair (" id" , tr->id .GetHex ()));
197+ jtr.push_back (Pair (" from" , tr->fromCurrency ));
198+ jtr.push_back (Pair (" from address" , tr->from ));
199+ double fromAmount = static_cast <double >(tr->fromAmount ) / XBridgeTransactionDescr::COIN;
195200 jtr.push_back (Pair (" fromAmount" , boost::lexical_cast<std::string>(fromAmount)));
196- jtr.push_back (Pair (" to" , tr->b_currency () ));
197- jtr.push_back (Pair (" to address" , tr->a_destination () ));
198- double toAmount = static_cast <double >(tr->b_amount () ) / XBridgeTransactionDescr::COIN;
201+ jtr.push_back (Pair (" to" , tr->toCurrency ));
202+ jtr.push_back (Pair (" to address" , tr->to ));
203+ double toAmount = static_cast <double >(tr->toAmount ) / XBridgeTransactionDescr::COIN;
199204 jtr.push_back (Pair (" toAmount" , boost::lexical_cast<std::string>(toAmount)));
200205 jtr.push_back (Pair (" state" , tr->strState ()));
201206
0 commit comments