2424import org .springframework .beans .factory .annotation .Autowired ;
2525import org .springframework .stereotype .Component ;
2626import org .springframework .util .StringUtils ;
27- import org .tron .core .db .api .index .AccountIndex ;
28- import org .tron .core .db .api .index .AssetIssueIndex ;
29- import org .tron .core .db .api .index .BlockIndex ;
30- import org .tron .core .db .api .index .TransactionIndex ;
31- import org .tron .core .db .api .index .WitnessIndex ;
27+ import org .tron .core .db .api .index .*;
3228import org .tron .core .db .common .WrappedByteArray ;
3329import org .tron .core .exception .NonUniqueObjectException ;
3430import org .tron .protos .Contract .AssetIssueContract ;
@@ -49,7 +45,7 @@ public class StoreAPI {
4945 * *******************************************************************************
5046 */
5147 public List <Account > getAccountAll () {
52- AccountIndex index = indexHelper .getAccountIndex ();
48+ Index . Iface < Account > index = indexHelper .getAccountIndex ();
5349 return ImmutableList .copyOf (index );
5450 }
5551
@@ -58,8 +54,8 @@ public Account getAccountByAddress(String address) throws NonUniqueObjectExcepti
5854 logger .info ("address is empty" );
5955 return null ;
6056 }
61- AccountIndex index = indexHelper .getAccountIndex ();
62- ResultSet <Account > resultSet = index .retrieve (equal (index .Account_ADDRESS , address ));
57+ Index . Iface < Account > index = indexHelper .getAccountIndex ();
58+ ResultSet <Account > resultSet = index .retrieve (equal (AccountIndex .Account_ADDRESS , address ));
6359
6460 if (resultSet .isEmpty ()) {
6561 return null ;
@@ -73,7 +69,7 @@ public Account getAccountByAddress(String address) throws NonUniqueObjectExcepti
7369 }
7470
7571 public long getAccountCount () {
76- AccountIndex index = indexHelper .getAccountIndex ();
72+ Index . Iface < Account > index = indexHelper .getAccountIndex ();
7773 return index .size ();
7874 }
7975
@@ -82,13 +78,13 @@ public long getAccountCount() {
8278 * *******************************************************************************
8379 */
8480 public long getBlockCount () {
85- BlockIndex index = indexHelper .getBlockIndex ();
81+ Index . Iface < Block > index = indexHelper .getBlockIndex ();
8682 return index .size ();
8783 }
8884
8985 public Block getBlockByNumber (long number ) throws NonUniqueObjectException {
90- BlockIndex index = indexHelper .getBlockIndex ();
91- ResultSet <Block > resultSet = index .retrieve (equal (index .Block_NUMBER , number ));
86+ Index . Iface < Block > index = indexHelper .getBlockIndex ();
87+ ResultSet <Block > resultSet = index .retrieve (equal (BlockIndex .Block_NUMBER , number ));
9288
9389 if (resultSet .isEmpty ()) {
9490 return null ;
@@ -106,8 +102,8 @@ public Block getBlockByTransactionId(String transactionId) throws NonUniqueObjec
106102 logger .info ("transactionId is empty" );
107103 return null ;
108104 }
109- BlockIndex index = indexHelper .getBlockIndex ();
110- ResultSet <Block > resultSet = index .retrieve (equal (index .TRANSACTIONS , transactionId ));
105+ Index . Iface < Block > index = indexHelper .getBlockIndex ();
106+ ResultSet <Block > resultSet = index .retrieve (equal (BlockIndex .TRANSACTIONS , transactionId ));
111107
112108 if (resultSet .isEmpty ()) {
113109 return null ;
@@ -126,12 +122,12 @@ public List<Block> getBlocksRelatedToAccount(String accountAddress) {
126122 return Lists .newArrayList ();
127123 }
128124
129- BlockIndex index = indexHelper .getBlockIndex ();
125+ Index . Iface < Block > index = indexHelper .getBlockIndex ();
130126 ResultSet <Block > resultSet =
131127 index .retrieve (
132- or (equal (index .OWNERS , accountAddress ), equal (index .TOS , accountAddress )),
128+ or (equal (BlockIndex .OWNERS , accountAddress ), equal (BlockIndex .TOS , accountAddress )),
133129 queryOptions (
134- orderBy (descending (index .Block_NUMBER )),
130+ orderBy (descending (BlockIndex .Block_NUMBER )),
135131 applyThresholds (threshold (INDEX_ORDERING_SELECTIVITY , 1.0 ))));
136132
137133 return ImmutableList .copyOf (resultSet );
@@ -142,24 +138,24 @@ public List<Block> getBlocksByWitnessAddress(String WitnessAddress) {
142138 logger .info ("WitnessAddress is empty" );
143139 return Lists .newArrayList ();
144140 }
145- BlockIndex index = indexHelper .getBlockIndex ();
141+ Index . Iface < Block > index = indexHelper .getBlockIndex ();
146142 ResultSet <Block > resultSet =
147143 index .retrieve (
148- equal (index .WITNESS_ADDRESS , WitnessAddress ),
144+ equal (BlockIndex .WITNESS_ADDRESS , WitnessAddress ),
149145 queryOptions (
150- orderBy (descending (index .Block_NUMBER )),
146+ orderBy (descending (BlockIndex .Block_NUMBER )),
151147 applyThresholds (threshold (INDEX_ORDERING_SELECTIVITY , 1.0 ))));
152148
153149 return ImmutableList .copyOf (resultSet );
154150 }
155151
156152 public List <Block > getBlocksByWitnessId (Long witnessId ) {
157- BlockIndex index = indexHelper .getBlockIndex ();
153+ Index . Iface < Block > index = indexHelper .getBlockIndex ();
158154 ResultSet <Block > resultSet =
159155 index .retrieve (
160- equal (index .WITNESS_ID , witnessId ),
156+ equal (BlockIndex .WITNESS_ID , witnessId ),
161157 queryOptions (
162- orderBy (descending (index .Block_NUMBER )),
158+ orderBy (descending (BlockIndex .Block_NUMBER )),
163159 applyThresholds (threshold (INDEX_ORDERING_SELECTIVITY , 1.0 ))));
164160
165161 return ImmutableList .copyOf (resultSet );
@@ -170,12 +166,12 @@ public List<Block> getLatestBlocks(int topN) {
170166 return Collections .emptyList ();
171167 }
172168
173- BlockIndex index = indexHelper .getBlockIndex ();
169+ Index . Iface < Block > index = indexHelper .getBlockIndex ();
174170 ResultSet <Block > resultSet =
175171 index .retrieve (
176172 all (WrappedByteArray .class ),
177173 queryOptions (
178- orderBy (descending (index .Block_NUMBER )),
174+ orderBy (descending (BlockIndex .Block_NUMBER )),
179175 applyThresholds (threshold (INDEX_ORDERING_SELECTIVITY , 1.0 ))));
180176
181177 return ImmutableList .copyOf (Streams .stream (resultSet ).limit (topN ).iterator ());
@@ -186,7 +182,7 @@ public List<Block> getLatestBlocks(int topN) {
186182 * *******************************************************************************
187183 */
188184 public long getTransactionCount () {
189- TransactionIndex index = indexHelper .getTransactionIndex ();
185+ Index . Iface < Transaction > index = indexHelper .getTransactionIndex ();
190186 return index .size ();
191187 }
192188
@@ -195,8 +191,8 @@ public Transaction getTransactionById(String id) throws NonUniqueObjectException
195191 logger .info ("id is empty" );
196192 return null ;
197193 }
198- TransactionIndex index = indexHelper .getTransactionIndex ();
199- ResultSet <Transaction > resultSet = index .retrieve (equal (index .Transaction_ID , id ));
194+ Index . Iface < Transaction > index = indexHelper .getTransactionIndex ();
195+ ResultSet <Transaction > resultSet = index .retrieve (equal (TransactionIndex .Transaction_ID , id ));
200196
201197 if (resultSet .isEmpty ()) {
202198 return null ;
@@ -214,12 +210,12 @@ public List<Transaction> getTransactionsFromThis(String address) {
214210 logger .info ("address is empty" );
215211 return Lists .newArrayList ();
216212 }
217- TransactionIndex index = indexHelper .getTransactionIndex ();
213+ Index . Iface < Transaction > index = indexHelper .getTransactionIndex ();
218214 ResultSet <Transaction > resultSet =
219215 index .retrieve (
220- equal (index .OWNERS , address ),
216+ equal (TransactionIndex .OWNERS , address ),
221217 queryOptions (
222- orderBy (descending (index .TIMESTAMP )),
218+ orderBy (descending (TransactionIndex .TIMESTAMP )),
223219 applyThresholds (threshold (INDEX_ORDERING_SELECTIVITY , 1.0 ))));
224220
225221 return ImmutableList .copyOf (resultSet );
@@ -230,12 +226,12 @@ public List<Transaction> getTransactionsToThis(String address) {
230226 logger .info ("address is empty" );
231227 return Lists .newArrayList ();
232228 }
233- TransactionIndex index = indexHelper .getTransactionIndex ();
229+ Index . Iface < Transaction > index = indexHelper .getTransactionIndex ();
234230 ResultSet <Transaction > resultSet =
235231 index .retrieve (
236- equal (index .TOS , address ),
232+ equal (TransactionIndex .TOS , address ),
237233 queryOptions (
238- orderBy (descending (index .TIMESTAMP )),
234+ orderBy (descending (TransactionIndex .TIMESTAMP )),
239235 applyThresholds (threshold (INDEX_ORDERING_SELECTIVITY , 1.0 ))));
240236
241237 return ImmutableList .copyOf (resultSet );
@@ -246,14 +242,14 @@ public List<Transaction> getTransactionsRelatedToAccount(String accountAddress)
246242 logger .info ("accountAddress is empty" );
247243 return Lists .newArrayList ();
248244 }
249- TransactionIndex index = indexHelper .getTransactionIndex ();
245+ Index . Iface < Transaction > index = indexHelper .getTransactionIndex ();
250246 ResultSet <Transaction > resultSet =
251247 index .retrieve (
252248 or (
253- equal (index .OWNERS , accountAddress ),
254- equal (index .TOS , accountAddress )),
249+ equal (TransactionIndex .OWNERS , accountAddress ),
250+ equal (TransactionIndex .TOS , accountAddress )),
255251 queryOptions (
256- orderBy (descending (index .TIMESTAMP )),
252+ orderBy (descending (TransactionIndex .TIMESTAMP )),
257253 applyThresholds (threshold (INDEX_ORDERING_SELECTIVITY , 1.0 ))));
258254
259255 return ImmutableList .copyOf (resultSet );
@@ -265,12 +261,12 @@ public List<Transaction> getTransactionsByTimestamp(
265261 return Collections .emptyList ();
266262 }
267263
268- TransactionIndex index = indexHelper .getTransactionIndex ();
264+ Index . Iface < Transaction > index = indexHelper .getTransactionIndex ();
269265 ResultSet <Transaction > resultSet =
270266 index .retrieve (
271- between (index .TIMESTAMP , beginInMilliseconds , endInMilliseconds ),
267+ between (TransactionIndex .TIMESTAMP , beginInMilliseconds , endInMilliseconds ),
272268 queryOptions (
273- orderBy (descending (index .TIMESTAMP )),
269+ orderBy (descending (TransactionIndex .TIMESTAMP )),
274270 applyThresholds (threshold (INDEX_ORDERING_SELECTIVITY , 1.0 ))));
275271
276272 return ImmutableList .copyOf (resultSet );
@@ -281,12 +277,12 @@ public List<Transaction> getLatestTransactions(int topN) {
281277 return Collections .emptyList ();
282278 }
283279
284- TransactionIndex index = indexHelper .getTransactionIndex ();
280+ Index . Iface < Transaction > index = indexHelper .getTransactionIndex ();
285281 ResultSet <Transaction > resultSet =
286282 index .retrieve (
287283 all (WrappedByteArray .class ),
288284 queryOptions (
289- orderBy (descending (index .TIMESTAMP )),
285+ orderBy (descending (TransactionIndex .TIMESTAMP )),
290286 applyThresholds (threshold (INDEX_ORDERING_SELECTIVITY , 1.0 ))));
291287
292288 return ImmutableList .copyOf (Streams .stream (resultSet ).limit (topN ).iterator ());
@@ -297,7 +293,7 @@ public List<Transaction> getLatestTransactions(int topN) {
297293 * *******************************************************************************
298294 */
299295 public List <Witness > getWitnessAll () {
300- WitnessIndex index = indexHelper .getWitnessIndex ();
296+ Index . Iface < Witness > index = indexHelper .getWitnessIndex ();
301297 return ImmutableList .copyOf (index );
302298 }
303299
@@ -306,8 +302,8 @@ public Witness getWitnessByAddress(String address) throws NonUniqueObjectExcepti
306302 logger .info ("address is empty" );
307303 return null ;
308304 }
309- WitnessIndex index = indexHelper .getWitnessIndex ();
310- ResultSet <Witness > resultSet = index .retrieve (equal (index .Witness_ADDRESS , address ));
305+ Index . Iface < Witness > index = indexHelper .getWitnessIndex ();
306+ ResultSet <Witness > resultSet = index .retrieve (equal (WitnessIndex .Witness_ADDRESS , address ));
311307
312308 if (resultSet .isEmpty ()) {
313309 return null ;
@@ -325,8 +321,8 @@ public Witness getWitnessByUrl(String url) throws NonUniqueObjectException {
325321 logger .info ("url is empty" );
326322 return null ;
327323 }
328- WitnessIndex index = indexHelper .getWitnessIndex ();
329- ResultSet <Witness > resultSet = index .retrieve (equal (index .Witness_URL , url ));
324+ Index . Iface < Witness > index = indexHelper .getWitnessIndex ();
325+ ResultSet <Witness > resultSet = index .retrieve (equal (WitnessIndex .Witness_URL , url ));
330326
331327 if (resultSet .isEmpty ()) {
332328 return null ;
@@ -344,8 +340,8 @@ public Witness getWitnessByPublicKey(String publicKey) throws NonUniqueObjectExc
344340 logger .info ("publicKey is empty" );
345341 return null ;
346342 }
347- WitnessIndex index = indexHelper .getWitnessIndex ();
348- ResultSet <Witness > resultSet = index .retrieve (equal (index .PUBLIC_KEY , publicKey ));
343+ Index . Iface < Witness > index = indexHelper .getWitnessIndex ();
344+ ResultSet <Witness > resultSet = index .retrieve (equal (WitnessIndex .PUBLIC_KEY , publicKey ));
349345
350346 if (resultSet .isEmpty ()) {
351347 return null ;
@@ -359,7 +355,7 @@ public Witness getWitnessByPublicKey(String publicKey) throws NonUniqueObjectExc
359355 }
360356
361357 public long getWitnessCount () {
362- WitnessIndex index = indexHelper .getWitnessIndex ();
358+ Index . Iface < Witness > index = indexHelper .getWitnessIndex ();
363359 return index .size ();
364360 }
365361
@@ -368,19 +364,19 @@ public long getWitnessCount() {
368364 * *******************************************************************************
369365 */
370366 public List <AssetIssueContract > getAssetIssueAll () {
371- AssetIssueIndex index = indexHelper .getAssetIssueIndex ();
367+ Index . Iface < AssetIssueContract > index = indexHelper .getAssetIssueIndex ();
372368 return ImmutableList .copyOf (index );
373369 }
374370
375371 public List <AssetIssueContract > getAssetIssueByTime (long currentInMilliseconds ) {
376- AssetIssueIndex index = indexHelper .getAssetIssueIndex ();
372+ Index . Iface < AssetIssueContract > index = indexHelper .getAssetIssueIndex ();
377373 ResultSet <AssetIssueContract > resultSet =
378374 index .retrieve (
379375 and (
380- lessThan (index .AssetIssue_START , currentInMilliseconds ),
381- greaterThanOrEqualTo (index .AssetIssue_END , currentInMilliseconds )),
376+ lessThan (AssetIssueIndex .AssetIssue_START , currentInMilliseconds ),
377+ greaterThanOrEqualTo (AssetIssueIndex .AssetIssue_END , currentInMilliseconds )),
382378 queryOptions (
383- orderBy (descending (index .AssetIssue_END )),
379+ orderBy (descending (AssetIssueIndex .AssetIssue_END )),
384380 applyThresholds (threshold (INDEX_ORDERING_SELECTIVITY , 1.0 ))));
385381
386382 return ImmutableList .copyOf (resultSet );
@@ -391,9 +387,9 @@ public AssetIssueContract getAssetIssueByName(String name) throws NonUniqueObjec
391387 logger .info ("name is empty" );
392388 return null ;
393389 }
394- AssetIssueIndex index = indexHelper .getAssetIssueIndex ();
390+ Index . Iface < AssetIssueContract > index = indexHelper .getAssetIssueIndex ();
395391 ResultSet <AssetIssueContract > resultSet =
396- index .retrieve (equal (index .AssetIssue_NAME , name ));
392+ index .retrieve (equal (AssetIssueIndex .AssetIssue_NAME , name ));
397393
398394 if (resultSet .isEmpty ()) {
399395 return null ;
@@ -411,9 +407,9 @@ public List<AssetIssueContract> getAssetIssueByOwnerAddress(String ownerAddress)
411407 logger .info ("ownerAddress is empty" );
412408 return Lists .newArrayList ();
413409 }
414- AssetIssueIndex index = indexHelper .getAssetIssueIndex ();
410+ Index . Iface < AssetIssueContract > index = indexHelper .getAssetIssueIndex ();
415411 ResultSet <AssetIssueContract > resultSet =
416- index .retrieve (equal (index .AssetIssue_OWNER_RADDRESS , ownerAddress ));
412+ index .retrieve (equal (AssetIssueIndex .AssetIssue_OWNER_RADDRESS , ownerAddress ));
417413
418414 return ImmutableList .copyOf (resultSet );
419415 }
0 commit comments