Skip to content

Commit 531ba20

Browse files
authored
Merge pull request #216 from yungwine/mytonctrl2_dev
dev
2 parents cb7b39e + 506c4cc commit 531ba20

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

mytoncore/mytoncore.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,7 +1316,6 @@ def GetStake(self, account, args=None):
13161316
# Limit stake to maximum available amount minus 10 (for transaction fees)
13171317
if stake > account.balance - 10:
13181318
stake = account.balance - 10
1319-
#end if
13201319

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

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

13531352
return stake
1354-
#end define
13551353

13561354
def GetMaxFactor(self):
13571355
# Either use defined maxFactor, or set maximal allowed by config17

mytonctrl/mytonctrl.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,20 +176,38 @@ def inject_globals(func):
176176
local.db.config.logLevel = "debug" if console.debug else "info"
177177
local.db.config.isLocaldbSaving = False
178178
local.run()
179+
180+
181+
def check_installer_user():
182+
args = ["whoami"]
183+
process = subprocess.run(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=3)
184+
username = process.stdout.decode("utf-8").strip()
185+
186+
args = ["ls", "-lh", "/var/ton-work/keys/"]
187+
process = subprocess.run(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=3)
188+
output = process.stdout.decode("utf-8")
189+
actual_user = output.split('\n')[1].split()[2]
190+
191+
if username != actual_user:
192+
raise Exception(f'mytonctrl was installed by another user. Probably you need to launch mtc with `{actual_user}` user.')
179193
#end define
180194

195+
181196
def PreUp(local, ton):
182197
CheckMytonctrlUpdate(local)
198+
check_installer_user()
183199
check_vport(local, ton)
184200
# CheckTonUpdate()
185201
#end define
186202

203+
187204
def Installer(args):
188205
# args = ["python3", "/usr/src/mytonctrl/mytoninstaller.py"]
189206
args = ["python3", "-m", "mytoninstaller"]
190207
subprocess.run(args)
191208
#end define
192209

210+
193211
def GetAuthorRepoBranchFromArgs(args):
194212
data = dict()
195213
arg1 = GetItemFromList(args, 0)
@@ -210,6 +228,7 @@ def GetAuthorRepoBranchFromArgs(args):
210228
return data
211229
#end define
212230

231+
213232
def check_vport(local, ton):
214233
try:
215234
vconfig = ton.GetValidatorConfig()
@@ -245,7 +264,8 @@ def check_git(input_args, default_repo, text):
245264
git_path = f"{src_dir}/{default_repo}"
246265
fix_git_config(git_path)
247266
default_author = "ton-blockchain"
248-
default_branch = "master"
267+
# default_branch = "master"
268+
default_branch = "mytonctrl2"
249269

250270
# Get author, repo, branch
251271
local_author, local_repo = get_git_author_and_repo(git_path)

0 commit comments

Comments
 (0)