@@ -136,6 +136,8 @@ class Ethplorer {
136
136
137
137
protected $ useOperations2 = FALSE ;
138
138
139
+ protected $ getTokensCacheCreation = FALSE ;
140
+
139
141
/**
140
142
* Constructor.
141
143
*
@@ -977,7 +979,10 @@ public function getTokens($updateCache = false){
977
979
return $ this ->aTokens ;
978
980
}
979
981
$ aResult = $ this ->oCache ->get ('tokens ' , false , true );
980
- if ($ updateCache || (false === $ aResult )){
982
+ if (!$ this ->getTokensCacheCreation && ($ updateCache/* || (false === $aResult)*/ )){
983
+ // Recursion protection
984
+ $ this ->getTokensCacheCreation = true ;
985
+
981
986
evxProfiler::checkpoint ('getTokens ' , 'START ' );
982
987
$ aPrevTokens = array ();
983
988
if ($ updateCache ){
@@ -995,9 +1000,7 @@ public function getTokens($updateCache = false){
995
1000
unset($ aToken ["_id " ]);
996
1001
$ aResult [$ address ] = $ aToken ;
997
1002
if (!isset ($ aPrevTokens [$ address ]) || ($ aPrevTokens [$ address ]['transfersCount ' ] < $ aToken ['transfersCount ' ])){
998
- if (defined ('ETHPLORER_SHOW_OUTPUT ' )){
999
- echo $ address . " was recently updated (transfers count = " . $ aToken ['transfersCount ' ] . ") \n" ;
1000
- }
1003
+ $ this ->_cliDebug ($ address . " was recently updated (transfers count = " . $ aToken ['transfersCount ' ] . ") " );
1001
1004
$ aResult [$ address ]['issuancesCount ' ] = $ this ->getContractOperationCount (array ('$in ' => array ('issuance ' , 'burn ' , 'mint ' )), $ address , FALSE );
1002
1005
$ hc = $ this ->getTokenHoldersCount ($ address );;
1003
1006
if (FALSE !== $ hc ){
@@ -2081,7 +2084,7 @@ protected function _sortByTxCount($a, $b){
2081
2084
public function getTokenHistoryGrouped ($ period = 30 , $ address = FALSE , $ type = 'daily ' , $ cacheLifetime = 1800 , $ showEth = FALSE , $ updateCache = FALSE ){
2082
2085
$ cache = 'token_history_grouped- ' . ($ address ? ($ address . '- ' ) : '' ) . $ period . (($ type == 'hourly ' ) ? '-hourly ' : '' ) . ($ showEth ? '-eth ' : '' );
2083
2086
$ result = $ address ? $ this ->oCache ->get ($ cache , false , true , $ cacheLifetime ) : $ this ->oCache ->get ($ cache , false , true );
2084
- if (FALSE === $ result || $ updateCache ){
2087
+ if (( $ address && FALSE === $ result) || $ updateCache ){
2085
2088
// Chainy
2086
2089
if ($ address && ($ address == self ::ADDRESS_CHAINY )){
2087
2090
return $ this ->getChainyTokenHistoryGrouped ($ period );
@@ -2796,9 +2799,16 @@ public function getAddressPriceHistoryGrouped($address, $updateCache = FALSE, $w
2796
2799
$ result = false ;
2797
2800
$ updateCache = false ;
2798
2801
}
2799
-
2802
+
2800
2803
if (FALSE === $ result || $ updateCache ){
2801
- $ aSearch = array ('from ' , 'to ' , 'address ' );
2804
+
2805
+ $ opCount = $ this ->countOperations ($ address , FALSE );
2806
+ if ($ opCount >= 10000 ){
2807
+ evxProfiler::checkpoint ('getAddressPriceHistoryGrouped ' , 'FINISH ' , 'Address has >10000 operations, skip ' );
2808
+ return FALSE ;
2809
+ }
2810
+
2811
+ $ aSearch = array ('from ' , 'to ' , 'address ' ); // @todo: research "addresses"
2802
2812
$ aTypes = array ('transfer ' , 'issuance ' , 'burn ' , 'mint ' );
2803
2813
$ aResult = array ();
2804
2814
$ aContracts = array ();
@@ -3313,7 +3323,8 @@ protected function getEthToken(){
3313
3323
}
3314
3324
3315
3325
protected function _cliDebug ($ message ){
3316
- if (isset ($ this ->aSettings ['cliDebug ' ]) && $ this ->aSettings ['cliDebug ' ] && (php_sapi_name () === 'cli ' )){
3326
+ $ showDebug = ((isset ($ this ->aSettings ['cliDebug ' ]) && $ this ->aSettings ['cliDebug ' ]) || defined ('ETHPLORER_SHOW_OUTPUT ' )) && (php_sapi_name () === 'cli ' );
3327
+ if ($ showDebug ){
3317
3328
echo '[ ' . date ("Y-m-d H:i:s " ) . '] ' . $ message . "\n" ;
3318
3329
}
3319
3330
}
0 commit comments