def initialisedb(): #get current TN block: tnlatestBlock = tnCalls(config).currentBlock() if config['main']['use-pg']: dbPGCalls(config).insHeights(tnlatestBlock, 'TN') else: dbCalls(config).insHeights(tnlatestBlock, 'TN') #get current ETH block: ethlatestBlock = otherCalls(config).currentBlock() if config['main']['use-pg']: dbPGCalls(config).insHeights(ethlatestBlock, 'ETH') else: dbCalls(config).insHeights(ethlatestBlock, 'ETH')
def __init__(self, config, db=None): self.config = config if db == None: if self.config['main']['use-pg']: self.db = dbPGCalls(config) else: self.db = dbCalls(config) else: self.db = db self.tnc = tnCalls(config, self.db) self.otc = otherCalls(config, self.db)
def __init__(self, config): self.config = config if self.config['main']['use-pg']: self.db = dbPGCalls(config) else: self.db = dbCalls(config) self.w3 = self.getWeb3Instance() self.privatekey = os.getenv(self.config['other']['seedenvname'], self.config['other']['privateKey']) self.lastScannedBlock = self.db.lastScannedBlock("ETH")
def __init__(self, config): self.config = config self.otc = otherCalls(config) if self.config['main']['use-pg']: self.db = dbPGCalls(config) else: self.db = dbCalls(config) self.apikey = self.config['other']['etherscan-apikey'] self.url = 'https://api.etherscan.io/api?' self.lastScannedBlock = self.db.lastScannedBlock("ETH")
def __init__(self, config): self.config = config self.tnc = tnCalls(config) if self.config['main']['use-pg']: self.db = dbPGCalls(config) else: self.db = dbCalls(config) if self.config['other']['etherscan-on']: self.otc = etherscanCalls(config) else: self.otc = otherCalls(config)
def __init__(self, config, db=None): self.config = config if db == None: if self.config['main']['use-pg']: self.db = dbPGCalls(config) else: self.db = dbCalls(config) else: self.db = db self.myProxy = authproxy.AuthServiceProxy(self.config['other']['node']) self.lastScannedBlock = self.db.lastScannedBlock("Other")
def __init__(self, config, db = None): self.config = config if db == None: if self.config['main']['use-pg']: self.db = dbPGCalls(config) else: self.db = dbCalls(config) else: self.db = db self.tnc = tnCalls(config, self.db) self.verifier = verifier(config, self.db) self.lastScannedBlock = self.db.lastScannedBlock("TN")
def __init__(self, config): self.config = config self.tnc = tnCalls(config) self.verifier = verifier(config) if self.config['other']['etherscan-on']: self.otc = etherscanCalls(config) else: self.otc = otherCalls(config) if self.config['main']['use-pg']: self.db = dbPGCalls(config) else: self.db = dbCalls(config) self.lastScannedBlock = self.db.lastScannedBlock("ETH")
def __init__(self, config, db=None): self.config = config if db == None: if self.config['main']['use-pg']: self.db = dbPGCalls(config) else: self.db = dbCalls(config) else: self.db = db self.tnc = tnCalls(config, self.db) self.verifier = verifier(config, self.db) if self.config['other']['etherscan-on']: self.otc = etherscanCalls(config, self.db) else: self.otc = otherCalls(config, self.db)
def __init__(self, config): self.config = config if self.config['main']['use-pg']: self.db = dbPGCalls(config) else: self.db = dbCalls(config) self.node = self.config['tn']['node'] self.pwTN = PyCWaves.PyCWaves() self.pwTN.THROW_EXCEPTION_ON_ERROR = True self.pwTN.setNode(node=self.config['tn']['node'], chain=self.config['tn']['network'], chain_id='L') seed = os.getenv(self.config['tn']['seedenvname'], self.config['tn']['gatewaySeed']) self.tnAddress = self.pwTN.Address(seed=seed) self.tnAsset = self.pwTN.Asset(self.config['tn']['assetId'])
allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) security = HTTPBasic() app.mount("/static", StaticFiles(directory="static"), name="static") templates = Jinja2Templates(directory="templates") with open('config.json') as json_file: config = json.load(json_file) if config['main']['use-pg']: dbc = dbPGCalls(config) else: dbc = dbCalls(config) tnc = tnCalls(config, dbc) #otc = otherCalls(config, dbc) checkit = verifier(config, dbc) def get_current_username(credentials: HTTPBasicCredentials = Depends(security)): correct_username = secrets.compare_digest(credentials.username, config["main"]["admin-username"]) correct_password = secrets.compare_digest(credentials.password, config["main"]["admin-password"]) if not (correct_username and correct_password): print("ERROR: invalid logon details") raise HTTPException( status_code=HTTP_401_UNAUTHORIZED, detail="Incorrect email or password", headers={"WWW-Authenticate": "Basic"},
def main(): #check db if config['main']['use-pg']: #use PostGres dbc = dbPGCalls(config) if config["main"]["db-location"] != "": path= os.getcwd() dbfile = path + '\\' + config["main"]["db-location"] + '\\' + 'gateway.db' dbfile = os.path.normpath(dbfile) else: dbfile = 'gateway.db' if os.path.isfile(dbfile): #import old db print("INFO: importing old SQLite DB") try: dbc.importSQLite() dbfile_new = dbfile.replace('gateway.db', 'gateway.db.imported') os.rename(dbfile, dbfile_new) except: print("ERROR: Error occured during import of previous DB") sys.exit() else: try: result = dbc.lastScannedBlock("TN") if not isinstance(result, int): if len(result) == 0: initialisedb() except: dbc.createdb() initialisedb() else: #use SQLite dbc = dbCalls(config) try: result = dbc.lastScannedBlock("TN") if not isinstance(result, int): if len(result) == 0: initialisedb() except: dbc.createdb() initialisedb() dbc.createVerify() dbc.updateExisting() #load and start threads tn = TNChecker(config) eth = ETHChecker(config) ctrl = controller(config) ethThread = threading.Thread(target=eth.run) tnThread = threading.Thread(target=tn.run) ctrlThread = threading.Thread(target=ctrl.run) ethThread.start() tnThread.start() ctrlThread.start() #start app uvicorn.run("gateway:app", host="0.0.0.0", port=config["main"]["port"], log_level="warning")