db optimizations
This commit is contained in:
parent
a6f858671e
commit
9e047a214a
|
@ -31,7 +31,7 @@ def register(update, context):
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
account_index = wallet.new_account(label=un)
|
account = wallet.new_account(label=un)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f'Unable to create a new account in wallet RPC: {e}. Debug: {msg}')
|
logging.error(f'Unable to create a new account in wallet RPC: {e}. Debug: {msg}')
|
||||||
msg.reply_text('Unable to create a new account for you. Ask for help.')
|
msg.reply_text('Unable to create a new account for you. Ask for help.')
|
||||||
|
@ -40,7 +40,8 @@ def register(update, context):
|
||||||
u = User(
|
u = User(
|
||||||
telegram_id=uid,
|
telegram_id=uid,
|
||||||
telegram_user=un,
|
telegram_user=un,
|
||||||
account_index=account_index,
|
account_index=account[0],
|
||||||
|
address=account[1]
|
||||||
)
|
)
|
||||||
u.save()
|
u.save()
|
||||||
reply_text = [
|
reply_text = [
|
||||||
|
|
|
@ -9,6 +9,7 @@ class BaseModel(Model):
|
||||||
database = db
|
database = db
|
||||||
|
|
||||||
class User(BaseModel):
|
class User(BaseModel):
|
||||||
telegram_id = IntegerField()
|
telegram_id = IntegerField(unique=True)
|
||||||
telegram_user = CharField()
|
telegram_user = CharField(unique=True)
|
||||||
account_index = IntegerField()
|
account_index = IntegerField(unique=True)
|
||||||
|
address = CharField(unique=True)
|
||||||
|
|
|
@ -51,7 +51,7 @@ class Wallet(object):
|
||||||
|
|
||||||
def new_account(self, label=None):
|
def new_account(self, label=None):
|
||||||
_account = self.make_wallet_rpc('create_account', {'label': label})
|
_account = self.make_wallet_rpc('create_account', {'label': label})
|
||||||
return _account['account_index']
|
return (_account['account_index'], _account['address'])
|
||||||
|
|
||||||
def addresses(self, account, addr_indices=None):
|
def addresses(self, account, addr_indices=None):
|
||||||
qdata = {'account_index': account}
|
qdata = {'account_index': account}
|
||||||
|
|
Loading…
Reference in New Issue