@@ -607,92 +607,10 @@ async def get_plugin_fees(currency):
607607
608608 if res == OS_ERROR or res == OTHER_EXCEPTION :
609609 return None
610-
610+
611611 return res
612612
613613
614- # gethistory with caching part, not working in state
615- async def gethistory_alt (params ):
616- currency = params [0 ]
617- try :
618- addresses = json .loads (params [1 ])
619- except TypeError as e :
620- addresses = params [1 ]
621- except JSONDecodeError as e :
622- addresses = params [1 ]
623-
624- if type (addresses ) == str :
625- addresses = addresses .split (',' )
626-
627- if len (addresses ) == 0 or type (addresses ) != list :
628- return json .dumps ({})
629-
630- timestart = TimestampMillisec64 ()
631- logger .debug ("[server] " + str (timestart ) + " " + "xrmgethistory: " + currency + " - " + str (addresses ))
632-
633- if currency not in coins .keys ():
634- logger .warning ("[client] ERROR: Attempted to get history from unsupported coin " + currency )
635- return json .dumps ({})
636-
637- socket = coins [currency ]['socket' ]
638-
639- if type (addresses ) == str :
640- addresses = [addresses ]
641-
642- hashX_list = []
643- if type (addresses ) == list :
644- for addr in addresses :
645- print (addr )
646- if addr in hashx_cache :
647- hashX_list .append (hashx_cache [addr ])
648- else :
649- hashx = await socket .send_message ("gethashx" , [addr ], timeout = 15 )
650- logger .info (hashx )
651- hashx_cache [addr ] = hashx [0 ]
652- hashX_list .append (hashx [0 ])
653- else :
654- if addresses in hashx_cache :
655- print (addresses )
656- hashX_list .append (hashx_cache [addresses ])
657- else :
658- print (addresses )
659- hashx = await socket .send_message ("gethashx" , [addresses ], timeout = 15 )
660- logger .info (hashx )
661- hashx_cache [addresses ] = hashx [0 ]
662- hashX_list .append (hashx [0 ])
663-
664- # logger.info(hashX_list)
665- logging .info ("[server]*** gethistory, gethistoryhashx: [" + str (hashX_list ) + "]" )
666- res = await socket .send_message ("gethistoryhashx" , [hashX_list ], timeout = 15 )
667- logging .info ("[server]*** gethistory, res: " + str (res ) + " *** " + str (type (res )))
668- try :
669- json .loads (res )
670- valid_data = True
671- except Exception :
672- valid_data = False
673-
674- retries = 0
675- while valid_data is False and retries <= 3 :
676- logging .info ("[server] gethistory failed for coin: " + currency )
677-
678- retries += 1
679- res = await socket .send_message ("gethistoryhashx" , [hashX_list ], timeout = 15 )
680-
681- if res is None or res == OS_ERROR or res == OTHER_EXCEPTION or 'ERROR:' in res :
682- time .sleep (1 )
683- continue
684- else :
685- break
686-
687- if res is None or res == OS_ERROR or res == OTHER_EXCEPTION :
688- return json .dumps ({})
689-
690- logger .debug ("DEBUG MESSAGE: " + str (res ))
691- logger .info ("[server-end gethistory] completion time: {}ms" .format (TimestampMillisec64 () - timestart ))
692-
693- return json .dumps (res )
694-
695-
696614async def gethistory (params ):
697615 # VERSION WITHOUT CACHING
698616 currency = params [0 ]
@@ -732,56 +650,11 @@ async def gethistory(params):
732650 res = [e for e in res if e ]
733651
734652 logger .debug ("xrmgethistory: " + currency + " RES=\n " + str (res ))
735- # logger.info("[server-end gethistory] completion time: {}ms".format(TimestampMillisec64() - timestart))
653+ logger .info ("[server-end gethistory] completion time: {}ms" .format (TimestampMillisec64 () - timestart ))
736654
737655 return json .dumps (res )
738656
739657
740- # address_get_history(params), no more used, replaced by gethistory
741- async def address_get_history (params ):
742- currency = params [0 ]
743- try :
744- addresses = json .loads (params [1 ])
745- except TypeError as e :
746- addresses = params [1 ]
747- except JSONDecodeError as e :
748- addresses = params [1 ]
749-
750- if type (addresses ) == str :
751- addresses = addresses .split (',' )
752-
753- if len (addresses ) == 0 or type (addresses ) != list :
754- return None
755-
756- timestart = TimestampMillisec64 ()
757- logger .info ("[server] " + str (timestart ) + " " + "xrmgetaddresshistory: " + currency + " - " + str (addresses ))
758-
759- if currency not in coins .keys ():
760- logger .warning ("[client] ERROR: Attempted to get address history from unsupported coin " + currency )
761- return None
762-
763- socket = coins [currency ]['socket' ]
764-
765- try :
766- res = await socket .send_batch ("blockchain.address.get_history" , addresses , timeout = 60 )
767- except Exception :
768- logging .exception ("Exception occured while obtaining history" )
769-
770- return []
771-
772- if res is None or res == OS_ERROR or res == OTHER_EXCEPTION :
773- logging .info ("[server] getaddresshistory failed for coin: " + currency )
774-
775- return []
776-
777- if len (res ) == 1 :
778- res = res [0 ]
779-
780- logger .debug ("DEBUG MESSAGE: " + str (res ))
781- logger .info ("[server-end getaddresshistory] completion time: {}ms" .format (TimestampMillisec64 () - timestart ))
782-
783- return json .dumps (res )
784-
785658async def switchcase (requestjson ):
786659 switcher = {
787660 'getutxos' : getutxos (requestjson ['params' ]),
0 commit comments