diff --git a/README.md b/README.md index c577d8b4..4e9dc16a 100644 --- a/README.md +++ b/README.md @@ -58,12 +58,6 @@ Mytonctrl's documentation can be found at https://docs.ton.org/participate/run-n - [x] Show offers - [x] Vote for the proposal - [x] Automatic voting for previously voted proposals -- [x] Domain management - - [x] Rent a new domain - - [x] Show rented domains - - [x] Show domain status - - [x] Delete domain - - [ ] Automatic domain renewal - [x] Controlling the validator - [x] Participate in the election of a validator - [x] Return bet + reward diff --git a/mytoncore/functions.py b/mytoncore/functions.py index 0cca873a..1acec162 100755 --- a/mytoncore/functions.py +++ b/mytoncore/functions.py @@ -384,12 +384,6 @@ def Offers(local, ton): ton.VoteOffer(offer_hash) # end define - -def Domains(local, ton): - pass -# end define - - def Telemetry(local, ton): sendTelemetry = local.db.get("sendTelemetry") if sendTelemetry is not True: @@ -565,7 +559,6 @@ def General(local): local.start_cycle(Complaints, sec=t, args=(local, ton, )) local.start_cycle(Slashing, sec=t, args=(local, ton, )) - local.start_cycle(Domains, sec=600, args=(local, ton, )) local.start_cycle(Telemetry, sec=60, args=(local, ton, )) local.start_cycle(OverlayTelemetry, sec=7200, args=(local, ton, )) local.start_cycle(ScanLiteServers, sec=60, args=(local, ton,)) diff --git a/mytoncore/models.py b/mytoncore/models.py index 474fa276..db803d9b 100644 --- a/mytoncore/models.py +++ b/mytoncore/models.py @@ -41,15 +41,6 @@ def __init__(self, workchain, addr): #end class -class Domain(dict): - def __init__(self): - self["name"] = None - self["adnlAddr"] = None - self["walletName"] = None - #end define -#end class - - class Block(): def __init__(self, str=None): self.workchain = None diff --git a/mytoncore/mytoncore.py b/mytoncore/mytoncore.py index ed643083..e34baf14 100644 --- a/mytoncore/mytoncore.py +++ b/mytoncore/mytoncore.py @@ -19,7 +19,6 @@ from mytoncore.models import ( Wallet, Account, - Domain, Block, Trans, Message, @@ -390,48 +389,6 @@ def GetComment(self, body): return result #end define - def GetDomainAddr(self, domainName): - cmd = "dnsresolve {domainName} -1".format(domainName=domainName) - result = self.liteClient.Run(cmd) - if "not found" in result: - raise Exception("GetDomainAddr error: domain \"{domainName}\" not found".format(domainName=domainName)) - resolver = parse(result, "next resolver", '\n') - buff = resolver.replace(' ', '') - buffList = buff.split('=') - fullHexAddr = buffList[0] - addr = buffList[1] - return addr - #end define - - def GetDomainEndTime(self, domainName): - self.local.add_log("start GetDomainEndTime function", "debug") - buff = domainName.split('.') - subdomain = buff.pop(0) - dnsDomain = ".".join(buff) - dnsAddr = self.GetDomainAddr(dnsDomain) - - cmd = "runmethodfull {addr} getexpiration \"{subdomain}\"".format(addr=dnsAddr, subdomain=subdomain) - result = self.liteClient.Run(cmd) - result = parse(result, "result:", '\n') - result = parse(result, "[", "]") - result = result.replace(' ', '') - result = int(result) - return result - #end define - - def GetDomainAdnlAddr(self, domainName): - self.local.add_log("start GetDomainAdnlAddr function", "debug") - cmd = "dnsresolve {domainName} 1".format(domainName=domainName) - result = self.liteClient.Run(cmd) - lines = result.split('\n') - for line in lines: - if "adnl address" in line: - adnlAddr = parse(line, "=", "\n") - adnlAddr = adnlAddr.replace(' ', '') - adnlAddr = adnlAddr - return adnlAddr - #end define - def GetLocalWallet(self, walletName, version=None, subwallet=None): self.local.add_log("start GetLocalWallet function", "debug") if walletName is None: @@ -2898,76 +2855,6 @@ def GetItemFromDict(self, data, search): return None #end define - def GetDomainFromAuction(self, walletName, addr): - wallet = self.GetLocalWallet(walletName) - bocPath = self.local.buffer.my_temp_dir + "get_dns_data.boc" - bocData = bytes.fromhex("b5ee9c7241010101000e0000182fcb26a20000000000000000f36cae4d") - with open(bocPath, 'wb') as file: - file.write(bocData) - resultFilePath = self.SignBocWithWallet(wallet, bocPath, addr, 0.1) - self.SendFile(resultFilePath, wallet) - #end define - - def NewDomain(self, domain): - self.local.add_log("start NewDomain function", "debug") - domainName = domain["name"] - buff = domainName.split('.') - subdomain = buff.pop(0) - dnsDomain = ".".join(buff) - dnsAddr = self.GetDomainAddr(dnsDomain) - wallet = self.GetLocalWallet(domain["walletName"]) - expireInSec = 700000 # fix me - catId = 1 # fix me - - # Check if domain is busy - domainEndTime = self.GetDomainEndTime(domainName) - if domainEndTime > 0: - raise Exception("NewDomain error: domain is busy") - #end if - - fileName = self.tempDir + "dns-msg-body.boc" - args = ["auto-dns.fif", dnsAddr, "add", subdomain, expireInSec, "owner", wallet.addrB64, "cat", catId, "adnl", domain["adnlAddr"], "-o", fileName] - result = self.fift.Run(args) - resultFilePath = parse(result, "Saved to file ", ')') - resultFilePath = self.SignBocWithWallet(wallet, resultFilePath, dnsAddr, 1.7) - self.SendFile(resultFilePath, wallet) - self.AddDomain(domain) - #end define - - def AddDomain(self, domain): - if "domains" not in self.local.db: - self.local.db["domains"] = list() - #end if - self.local.db["domains"].append(domain) - self.local.save() - #end define - - def GetDomains(self): - domains = self.local.db.get("domains", list()) - for domain in domains: - domainName = domain.get("name") - domain["endTime"] = self.GetDomainEndTime(domainName) - return domains - #end define - - def GetDomain(self, domainName): - domain = dict() - domain["name"] = domainName - domain["adnlAddr"] = self.GetDomainAdnlAddr(domainName) - domain["endTime"] = self.GetDomainEndTime(domainName) - return domain - #end define - - def DeleteDomain(self, domainName): - domains = self.local.db.get("domains") - for domain in domains: - if (domainName == domain.get("name")): - domains.remove(domain) - self.local.save() - return - raise Exception("DeleteDomain error: Domain not found") - #end define - def GetAutoTransferRules(self): autoTransferRules = self.local.db.get("autoTransferRules") if autoTransferRules is None: @@ -3030,13 +2917,6 @@ def WriteBookmarkData(self, bookmark): data = "empty" else: data = account.balance - elif type == "domain": - domainName = bookmark.get("addr") - endTime = self.GetDomainEndTime(domainName) - if endTime == 0: - data = "free" - else: - data = timestamp2datetime(endTime, "%d.%m.%Y") else: data = "null" bookmark["data"] = data diff --git a/mytonctrl/mytonctrl.py b/mytonctrl/mytonctrl.py index 33224717..9b04fca6 100755 --- a/mytonctrl/mytonctrl.py +++ b/mytonctrl/mytonctrl.py @@ -101,16 +101,6 @@ def inject_globals(func): console.AddItem("bl", inject_globals(PrintBookmarksList), local.translate("bl_cmd")) console.AddItem("db", inject_globals(DeleteBookmark), local.translate("db_cmd")) - # console.AddItem("nr", inject_globals(CreatNewAutoTransferRule), local.translate("nr_cmd")) # "Добавить правило автопереводов в расписание / Create new auto transfer rule" - # console.AddItem("rl", inject_globals(PrintAutoTransferRulesList), local.translate("rl_cmd")) # "Показать правила автопереводов / Show auto transfer rule list" - # console.AddItem("dr", inject_globals(DeleteAutoTransferRule), local.translate("dr_cmd")) # "Удалить правило автопереводов из расписания / Delete auto transfer rule" - - # console.AddItem("nd", inject_globals(NewDomain), local.translate("nd_cmd")) - # console.AddItem("dl", inject_globals(PrintDomainsList), local.translate("dl_cmd")) - # console.AddItem("vds", inject_globals(ViewDomainStatus), local.translate("vds_cmd")) - # console.AddItem("dd", inject_globals(DeleteDomain), local.translate("dd_cmd")) - # console.AddItem("gdfa", inject_globals(GetDomainFromAuction), local.translate("gdfa_cmd")) - console.AddItem("ol", inject_globals(PrintOffersList), local.translate("ol_cmd")) console.AddItem("od", inject_globals(OfferDiff), local.translate("od_cmd")) @@ -315,7 +305,7 @@ def check_git(input_args, default_repo, text, default_branch='master'): need_branch = data.get("branch") # Check if remote repo is different from default - if ((need_author is None and local_author != default_author) or + if ((need_author is None and local_author != default_author) or (need_repo is None and local_repo != default_repo)): remote_url = f"https://github.com/{local_author}/{local_repo}/tree/{need_branch if need_branch else local_branch}" raise Exception(f"{text} error: You are on {remote_url} remote url, to update to the tip use `{text} {remote_url}` command") @@ -575,7 +565,7 @@ def PrintStatus(local, ton, args): config34 = ton.GetConfig34() config36 = ton.GetConfig36() totalValidators = config34["totalValidators"] - + if opt != "fast": onlineValidators = ton.GetOnlineValidators() validator_efficiency = ton.GetValidatorEfficiency() @@ -586,26 +576,26 @@ def PrintStatus(local, ton, args): if oldStartWorkTime is None: oldStartWorkTime = config34.get("startWorkTime") shardsNumber = ton.GetShardsNumber() - + config15 = ton.GetConfig15() config17 = ton.GetConfig17() fullConfigAddr = ton.GetFullConfigAddr() fullElectorAddr = ton.GetFullElectorAddr() startWorkTime = ton.GetActiveElectionId(fullElectorAddr) validator_index = ton.GetValidatorIndex() - + offersNumber = ton.GetOffersNumber() complaintsNumber = ton.GetComplaintsNumber() - + tpsAvg = ton.GetStatistics("tpsAvg", statistics) - + if validator_wallet is not None: validator_account = ton.GetAccount(validator_wallet.addrB64) #end if if all_status: PrintTonStatus(local, network_name, startWorkTime, totalValidators, onlineValidators, shardsNumber, offersNumber, complaintsNumber, tpsAvg) - PrintLocalStatus(local, adnl_addr, validator_index, validator_efficiency, validator_wallet, validator_account, validator_status, + PrintLocalStatus(local, adnl_addr, validator_index, validator_efficiency, validator_wallet, validator_account, validator_status, db_size, db_usage, memory_info, swap_info, net_load_avg, disks_load_avg, disks_load_percent_avg, fullnode_adnl) if all_status: PrintTonConfig(local, fullConfigAddr, fullElectorAddr, config15, config17) @@ -741,7 +731,7 @@ def PrintLocalStatus(local, adnlAddr, validatorIndex, validatorEfficiency, valid dbSize_text = GetColorInt(dbSize, 1000, logic="less", ending=" Gb") dbUsage_text = GetColorInt(dbUsage, 80, logic="less", ending="%") dbStatus_text = local.translate("local_status_db").format(dbSize_text, dbUsage_text) - + # Mytonctrl and validator git hash mtcGitPath = "/usr/src/mytonctrl" validatorGitPath = "/usr/src/ton" @@ -769,7 +759,7 @@ def PrintLocalStatus(local, adnlAddr, validatorIndex, validatorEfficiency, valid print(cpuLoad_text) print(netLoad_text) print(memoryLoad_text) - + print(disksLoad_text) print(mytoncoreStatus_text) print(validatorStatus_text) @@ -1087,12 +1077,10 @@ def CreatNewBookmark(ton, args): name = args[0] addr = args[1] except: - color_print("{red}Bad args. Usage:{endc} nb ") + color_print("{red}Bad args. Usage:{endc} nb ") return if ton.IsAddr(addr): type = "account" - else: - type = "domain" #end if bookmark = dict() @@ -1109,7 +1097,7 @@ def PrintBookmarksList(ton, args): print("No data") return table = list() - table += [["Name", "Type", "Address / Domain", "Balance / Exp. date"]] + table += [["Name", "Type", "Address", "Balance / Exp. date"]] for item in data: name = item.get("name") type = item.get("type") @@ -1130,36 +1118,6 @@ def DeleteBookmark(ton, args): color_print("DeleteBookmark - {green}OK{endc}") #end define -# def CreatNewAutoTransferRule(args): -# try: -# name = args[0] -# addr = args[1] -# except: -# color_print("{red}Bad args. Usage:{endc} nr ") -# return -# rule = dict() -# rule["name"] = name -# rule["addr"] = addr -# ton.AddAutoTransferRule(rule) -# color_print("CreatNewAutoTransferRule - {green}OK{endc}") -# #end define - -# def PrintAutoTransferRulesList(args): -# data = ton.GetRules() -# if (data is None or len(data) == 0): -# print("No data") -# return -# table = list() -# table += [["Name", "fix me"]] -# for item in data: -# table += [[item.get("name"), item.get("fix me")]] -# print_table(table) -# #end define - -# def DeleteAutoTransferRule(args): -# print("fix me") -# #end define - def PrintOffersList(ton, args): data = ton.GetOffers() if (data is None or len(data) == 0): @@ -1244,76 +1202,6 @@ def PrintComplaintsList(ton, args): print_table(table) #end define -def NewDomain(ton, args): - try: - domainName = args[0] - walletName = args[1] - adnlAddr = args[2] - except: - color_print("{red}Bad args. Usage:{endc} nd ") - return - domain = dict() - domain["name"] = domainName - domain["adnlAddr"] = adnlAddr - domain["walletName"] = walletName - ton.NewDomain(domain) - color_print("NewDomain - {green}OK{endc}") -#end define - -def PrintDomainsList(ton, args): - data = ton.GetDomains() - if (data is None or len(data) == 0): - print("No data") - return - table = list() - table += [["Domain", "Wallet", "Expiration date", "ADNL address"]] - for item in data: - domainName = item.get("name") - walletName = item.get("walletName") - endTime = item.get("endTime") - endTime = timestamp2datetime(endTime, "%d.%m.%Y") - adnlAddr = item.get("adnlAddr") - table += [[domainName, walletName, endTime, adnlAddr]] - print_table(table) -#end define - -def ViewDomainStatus(ton, args): - try: - domainName = args[0] - except: - color_print("{red}Bad args. Usage:{endc} vds ") - return - domain = ton.GetDomain(domainName) - endTime = domain.get("endTime") - endTime = timestamp2datetime(endTime, "%d.%m.%Y") - adnlAddr = domain.get("adnlAddr") - table = list() - table += [["Domain", "Expiration date", "ADNL address"]] - table += [[domainName, endTime, adnlAddr]] - print_table(table) -#end define - -def DeleteDomain(ton, args): - try: - domainName = args[0] - except: - color_print("{red}Bad args. Usage:{endc} dd ") - return - ton.DeleteDomain(domainName) - color_print("DeleteDomain - {green}OK{endc}") -#end define - -def GetDomainFromAuction(ton, args): - try: - walletName = args[0] - addr = args[1] - except: - color_print("{red}Bad args. Usage:{endc} gdfa ") - return - ton.GetDomainFromAuction(walletName, addr) - color_print("GetDomainFromAuction - {green}OK{endc}") -#end define - def PrintElectionEntriesList(ton, args): past = "past" in args data = ton.GetElectionEntries(past=past) diff --git a/mytonctrl/resources/translate.json b/mytonctrl/resources/translate.json index 7bbfcf1d..2caf4ec8 100644 --- a/mytonctrl/resources/translate.json +++ b/mytonctrl/resources/translate.json @@ -129,26 +129,6 @@ "ru": "Удалить закладку", "zh_TW": "刪除書籤" }, - "nd_cmd": { - "en": "New domain", - "ru": "Арендовать новый домен", - "zh_TW": "新建域名" - }, - "dl_cmd": { - "en": "Show domain list", - "ru": "Показать арендованные домены", - "zh_TW": "顯示域名列表" - }, - "vds_cmd": { - "en": "View domain status", - "ru": "Показать статус домена", - "zh_TW": "查看域名狀態" - }, - "dd_cmd": { - "en": "Delete domain", - "ru": "Удалить домен", - "zh_TW": "刪除域名" - }, "ol_cmd": { "en": "Show offers list", "ru": "Показать действующие предложения",