Skip to content
Merged

dev #216

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions mytoncore/mytoncore.py
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,6 @@ def GetStake(self, account, args=None):
# Limit stake to maximum available amount minus 10 (for transaction fees)
if stake > account.balance - 10:
stake = account.balance - 10
#end if

pool_version = self.GetVersionFromCodeHash(account.codeHash)
is_single_nominator = pool_version is not None and 'spool' in pool_version
Expand All @@ -1331,9 +1330,10 @@ def GetStake(self, account, args=None):
self.local.add_log("Wrong stakePercent value. Using default stake.", "warning")
elif len(vconfig.validators) == 0:
stake = int(account.balance*sp/2)
if stake < config17["minStake"]: # not enough funds to divide them by 2
stake = int(account.balance*sp)
elif len(vconfig.validators) > 0:
stake = int(account.balance*sp)
#end if

# Check if we have enough coins
if stake > config17["maxStake"]:
Expand All @@ -1348,10 +1348,8 @@ def GetStake(self, account, args=None):
text = "Don't have enough coins. stake: {stake}, account balance: {balance}".format(stake=stake, balance=account.balance)
# self.local.add_log(text, "error")
raise Exception(text)
#end if

return stake
#end define

def GetMaxFactor(self):
# Either use defined maxFactor, or set maximal allowed by config17
Expand Down
22 changes: 21 additions & 1 deletion mytonctrl/mytonctrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,20 +176,38 @@ def inject_globals(func):
local.db.config.logLevel = "debug" if console.debug else "info"
local.db.config.isLocaldbSaving = False
local.run()


def check_installer_user():
args = ["whoami"]
process = subprocess.run(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=3)
username = process.stdout.decode("utf-8").strip()

args = ["ls", "-lh", "/var/ton-work/keys/"]
process = subprocess.run(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=3)
output = process.stdout.decode("utf-8")
actual_user = output.split('\n')[1].split()[2]

if username != actual_user:
raise Exception(f'mytonctrl was installed by another user. Probably you need to launch mtc with `{actual_user}` user.')
#end define


def PreUp(local, ton):
CheckMytonctrlUpdate(local)
check_installer_user()
check_vport(local, ton)
# CheckTonUpdate()
#end define


def Installer(args):
# args = ["python3", "/usr/src/mytonctrl/mytoninstaller.py"]
args = ["python3", "-m", "mytoninstaller"]
subprocess.run(args)
#end define


def GetAuthorRepoBranchFromArgs(args):
data = dict()
arg1 = GetItemFromList(args, 0)
Expand All @@ -210,6 +228,7 @@ def GetAuthorRepoBranchFromArgs(args):
return data
#end define


def check_vport(local, ton):
try:
vconfig = ton.GetValidatorConfig()
Expand Down Expand Up @@ -245,7 +264,8 @@ def check_git(input_args, default_repo, text):
git_path = f"{src_dir}/{default_repo}"
fix_git_config(git_path)
default_author = "ton-blockchain"
default_branch = "master"
# default_branch = "master"
default_branch = "mytonctrl2"

# Get author, repo, branch
local_author, local_repo = get_git_author_and_repo(git_path)
Expand Down