Add certs folder to gitignore
This commit is contained in:
parent
a46f6ed3f3
commit
ccfb4d65bd
|
@ -5,3 +5,4 @@ env/
|
||||||
keys/
|
keys/
|
||||||
handler/settings.ini
|
handler/settings.ini
|
||||||
handler/otp.key
|
handler/otp.key
|
||||||
|
handler/certs/
|
||||||
|
|
|
@ -5,6 +5,8 @@ from twisted.logger import Logger
|
||||||
from json import dumps
|
from json import dumps
|
||||||
from random import choices
|
from random import choices
|
||||||
from string import ascii_uppercase
|
from string import ascii_uppercase
|
||||||
|
from elasticsearch import Elasticsearch
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
# Project imports
|
# Project imports
|
||||||
from settings import settings
|
from settings import settings
|
||||||
|
@ -23,6 +25,13 @@ class Transactions(object):
|
||||||
Set the logger.
|
Set the logger.
|
||||||
"""
|
"""
|
||||||
self.log = Logger("transactions")
|
self.log = Logger("transactions")
|
||||||
|
self.es = Elasticsearch(
|
||||||
|
f"https://{settings.ES.Host}:9200",
|
||||||
|
verify_certs=False,
|
||||||
|
basic_auth=(settings.ES.Username, settings.ES.Pass),
|
||||||
|
ssl_assert_fingerprint=("6b264fd2fd107d45652d8add1750a8a78f424542e13b056d0548173006260710"),
|
||||||
|
ca_certs="certs/ca.crt",
|
||||||
|
)
|
||||||
|
|
||||||
# TODO: write tests then refactor, this is terribly complicated!
|
# TODO: write tests then refactor, this is terribly complicated!
|
||||||
def transaction(self, data):
|
def transaction(self, data):
|
||||||
|
@ -466,11 +475,27 @@ class Transactions(object):
|
||||||
price_usd = total_usd
|
price_usd = total_usd
|
||||||
price_gbp = rates["GBP"] * total_usd
|
price_gbp = rates["GBP"] * total_usd
|
||||||
|
|
||||||
return (
|
cast = (
|
||||||
(price_sek, price_usd, price_gbp), # Total prices in our 3 favourite currencies
|
(price_sek, price_usd, price_gbp), # Total prices in our 3 favourite currencies
|
||||||
(total_usd_agora_xmr, total_usd_agora_btc), # Total USD balance in only Agora
|
(total_usd_agora_xmr, total_usd_agora_btc), # Total USD balance in only Agora
|
||||||
(total_xmr_agora, total_btc_agora),
|
(total_xmr_agora, total_btc_agora),
|
||||||
) # Total XMR and BTC balance in Agora
|
) # Total XMR and BTC balance in Agora
|
||||||
|
self.write_to_es("total", cast)
|
||||||
|
return cast
|
||||||
|
|
||||||
|
def write_to_es(self, msgtype, cast):
|
||||||
|
cast_remap = {
|
||||||
|
"type": msgtype,
|
||||||
|
"price_sek": cast[0][0],
|
||||||
|
"price_usd": cast[0][1],
|
||||||
|
"price_gbp": cast[0][2],
|
||||||
|
"total_usd_agora_xmr": cast[1][0],
|
||||||
|
"total_usd_agora_btc": cast[1][1],
|
||||||
|
"total_xmr_agora": cast[2][0],
|
||||||
|
"total_btc_agora": cast[2][1],
|
||||||
|
"ts": str(datetime.now().isoformat()),
|
||||||
|
}
|
||||||
|
self.es.index(index=settings.ES.Index, document=cast_remap)
|
||||||
|
|
||||||
def get_remaining(self):
|
def get_remaining(self):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue