quality fixes after pull
This commit is contained in:
parent
ee6f8f0fa7
commit
6650876b57
35
src/api.py
35
src/api.py
|
@ -3,16 +3,9 @@ This is not what you run to run the Bitmessage API. Instead, enable the API
|
||||||
( https://bitmessage.org/wiki/API ) and optionally enable daemon mode
|
( https://bitmessage.org/wiki/API ) and optionally enable daemon mode
|
||||||
( https://bitmessage.org/wiki/Daemon ) then run bitmessagemain.py.
|
( https://bitmessage.org/wiki/Daemon ) then run bitmessagemain.py.
|
||||||
"""
|
"""
|
||||||
<<<<<<< HEAD
|
|
||||||
# Copyright (c) 2012-2016 Jonathan Warren
|
# Copyright (c) 2012-2016 Jonathan Warren
|
||||||
# Copyright (c) 2012-2020 The Bitmessage developers
|
# Copyright (c) 2012-2020 The Bitmessage developers
|
||||||
# pylint: disable=too-many-lines,no-self-use,unused-variable,unused-argument
|
# pylint: disable=too-many-lines,no-self-use,unused-variable,unused-argument
|
||||||
=======
|
|
||||||
# pylint: disable=too-many-locals,too-many-lines,no-self-use,unused-argument
|
|
||||||
# pylint: disable=too-many-statements,too-many-public-methods,too-many-branches
|
|
||||||
# Copyright (c) 2012-2016 Jonathan Warren
|
|
||||||
# Copyright (c) 2012-2019 The Bitmessage developers
|
|
||||||
>>>>>>> 86df28c260eb1dd4acae506c1366f3cf136c5840
|
|
||||||
import base64
|
import base64
|
||||||
import errno
|
import errno
|
||||||
import hashlib
|
import hashlib
|
||||||
|
@ -34,7 +27,6 @@ import queues
|
||||||
import shared
|
import shared
|
||||||
import shutdown
|
import shutdown
|
||||||
import state
|
import state
|
||||||
<<<<<<< HEAD
|
|
||||||
from addresses import (
|
from addresses import (
|
||||||
addBMIfNotPresent,
|
addBMIfNotPresent,
|
||||||
calculateInventoryHash,
|
calculateInventoryHash,
|
||||||
|
@ -42,21 +34,13 @@ from addresses import (
|
||||||
decodeVarint,
|
decodeVarint,
|
||||||
varintDecodeError
|
varintDecodeError
|
||||||
)
|
)
|
||||||
=======
|
|
||||||
|
|
||||||
from addresses import addBMIfNotPresent, calculateInventoryHash, decodeAddress, decodeVarint, varintDecodeError
|
|
||||||
>>>>>>> 86df28c260eb1dd4acae506c1366f3cf136c5840
|
|
||||||
from bmconfigparser import BMConfigParser
|
from bmconfigparser import BMConfigParser
|
||||||
from debug import logger
|
from debug import logger
|
||||||
from helper_ackPayload import genAckPayload
|
from helper_ackPayload import genAckPayload
|
||||||
from helper_sql import SqlBulkExecute, sqlExecute, sqlQuery, sqlStoredProcedure
|
from helper_sql import SqlBulkExecute, sqlExecute, sqlQuery, sqlStoredProcedure
|
||||||
from inventory import Inventory
|
from inventory import Inventory
|
||||||
from network.threads import StoppableThread
|
from network.threads import StoppableThread
|
||||||
<<<<<<< HEAD
|
|
||||||
from version import softwareVersion
|
from version import softwareVersion
|
||||||
=======
|
|
||||||
# pylint: disable=unused-variable
|
|
||||||
>>>>>>> 86df28c260eb1dd4acae506c1366f3cf136c5840
|
|
||||||
|
|
||||||
str_chan = '[chan]'
|
str_chan = '[chan]'
|
||||||
|
|
||||||
|
@ -275,13 +259,9 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
raise APIError(9, 'Invalid characters in address: ' + address)
|
raise APIError(9, 'Invalid characters in address: ' + address)
|
||||||
if status == 'versiontoohigh':
|
if status == 'versiontoohigh':
|
||||||
raise APIError(
|
raise APIError(
|
||||||
<<<<<<< HEAD
|
|
||||||
10,
|
10,
|
||||||
'Address version number too high (or zero) in address: ' +
|
'Address version number too high (or zero) in address: ' +
|
||||||
address)
|
address)
|
||||||
=======
|
|
||||||
10, 'Address version number too high (or zero) in address: ' + address)
|
|
||||||
>>>>>>> 86df28c260eb1dd4acae506c1366f3cf136c5840
|
|
||||||
if status == 'varintmalformed':
|
if status == 'varintmalformed':
|
||||||
raise APIError(26, 'Malformed varint in address: ' + address)
|
raise APIError(26, 'Malformed varint in address: ' + address)
|
||||||
raise APIError(
|
raise APIError(
|
||||||
|
@ -645,13 +625,8 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
label = str_chan + ' ' + passphrase
|
label = str_chan + ' ' + passphrase
|
||||||
except BaseException:
|
except BaseException:
|
||||||
label = str_chan + ' ' + repr(passphrase)
|
label = str_chan + ' ' + repr(passphrase)
|
||||||
<<<<<<< HEAD
|
|
||||||
status, addressVersionNumber, streamNumber, toRipe = (
|
status, addressVersionNumber, streamNumber, toRipe = (
|
||||||
self._verifyAddress(suppliedAddress))
|
self._verifyAddress(suppliedAddress))
|
||||||
=======
|
|
||||||
status, addressVersionNumber, streamNumber, toRipe = self._verifyAddress(
|
|
||||||
suppliedAddress)
|
|
||||||
>>>>>>> 86df28c260eb1dd4acae506c1366f3cf136c5840
|
|
||||||
suppliedAddress = addBMIfNotPresent(suppliedAddress)
|
suppliedAddress = addBMIfNotPresent(suppliedAddress)
|
||||||
queues.apiAddressGeneratorReturnQueue.queue.clear()
|
queues.apiAddressGeneratorReturnQueue.queue.clear()
|
||||||
queues.addressGeneratorQueue.put((
|
queues.addressGeneratorQueue.put((
|
||||||
|
@ -674,13 +649,8 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
raise APIError(0, 'I need parameters.')
|
raise APIError(0, 'I need parameters.')
|
||||||
elif len(params) == 1:
|
elif len(params) == 1:
|
||||||
address, = params
|
address, = params
|
||||||
<<<<<<< HEAD
|
|
||||||
status, addressVersionNumber, streamNumber, toRipe = (
|
status, addressVersionNumber, streamNumber, toRipe = (
|
||||||
self._verifyAddress(address))
|
self._verifyAddress(address))
|
||||||
=======
|
|
||||||
status, addressVersionNumber, streamNumber, toRipe = \
|
|
||||||
self._verifyAddress(address)
|
|
||||||
>>>>>>> 86df28c260eb1dd4acae506c1366f3cf136c5840
|
|
||||||
address = addBMIfNotPresent(address)
|
address = addBMIfNotPresent(address)
|
||||||
if not BMConfigParser().has_section(address):
|
if not BMConfigParser().has_section(address):
|
||||||
raise APIError(
|
raise APIError(
|
||||||
|
@ -701,13 +671,8 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
||||||
raise APIError(0, 'I need parameters.')
|
raise APIError(0, 'I need parameters.')
|
||||||
elif len(params) == 1:
|
elif len(params) == 1:
|
||||||
address, = params
|
address, = params
|
||||||
<<<<<<< HEAD
|
|
||||||
status, addressVersionNumber, streamNumber, toRipe = (
|
status, addressVersionNumber, streamNumber, toRipe = (
|
||||||
self._verifyAddress(address))
|
self._verifyAddress(address))
|
||||||
=======
|
|
||||||
status, addressVersionNumber, streamNumber, toRipe = \
|
|
||||||
self._verifyAddress(address)
|
|
||||||
>>>>>>> 86df28c260eb1dd4acae506c1366f3cf136c5840
|
|
||||||
address = addBMIfNotPresent(address)
|
address = addBMIfNotPresent(address)
|
||||||
if not BMConfigParser().has_section(address):
|
if not BMConfigParser().has_section(address):
|
||||||
raise APIError(
|
raise APIError(
|
||||||
|
|
|
@ -96,33 +96,35 @@ def ShowTimeHistoy(act_time):
|
||||||
action_time = datetime.fromtimestamp(int(act_time))
|
action_time = datetime.fromtimestamp(int(act_time))
|
||||||
crnt_date = datetime.now()
|
crnt_date = datetime.now()
|
||||||
duration = crnt_date - action_time
|
duration = crnt_date - action_time
|
||||||
display_data = (action_time.strftime('%d/%m/%Y')
|
display_data = (
|
||||||
|
action_time.strftime('%d/%m/%Y')
|
||||||
if duration.days >= 365 else action_time.strftime('%I:%M %p').lstrip('0')
|
if duration.days >= 365 else action_time.strftime('%I:%M %p').lstrip('0')
|
||||||
if duration.days == 0 and crnt_date.strftime('%d/%m/%Y') == action_time.strftime('%d/%m/%Y')
|
if duration.days == 0 and crnt_date.strftime('%d/%m/%Y') == action_time.strftime('%d/%m/%Y')
|
||||||
else action_time.strftime("%d %b"))
|
else action_time.strftime("%d %b")
|
||||||
|
)
|
||||||
return display_data
|
return display_data
|
||||||
|
|
||||||
|
|
||||||
def AddTimeWidget(time):
|
def AddTimeWidget(time): # pylint: disable=redefined-outer-name
|
||||||
"""This method is used to create TimeWidget"""
|
"""This method is used to create TimeWidget"""
|
||||||
action_time = BadgeText(
|
action_time = BadgeText(
|
||||||
size_hint= (None, None),
|
size_hint=(None, None),
|
||||||
text= f"{ShowTimeHistoy(time)}",
|
text=str(ShowTimeHistoy(time)),
|
||||||
halign='right',
|
halign='right',
|
||||||
font_style='Caption',
|
font_style='Caption',
|
||||||
size= [65,70])
|
size=[65, 70])
|
||||||
return action_time
|
return action_time
|
||||||
|
|
||||||
|
|
||||||
def chipTag(text):
|
def chipTag(text):
|
||||||
"""This method is used for showing chip tag"""
|
"""This method is used for showing chip tag"""
|
||||||
obj = MDChip()
|
obj = MDChip()
|
||||||
obj.size_hint= (None, None)
|
obj.size_hint = (None, None)
|
||||||
obj.label= text
|
obj.label = text
|
||||||
obj.icon= ''
|
obj.icon = ''
|
||||||
obj.pos_hint= {'center_x': .96, 'center_y': .2}
|
obj.pos_hint = {'center_x': .96, 'center_y': .2}
|
||||||
obj.height= dp(18)
|
obj.height = dp(18)
|
||||||
obj.radius= 8
|
obj.radius = 8
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
|
|
||||||
|
@ -168,12 +170,13 @@ class Inbox(Screen):
|
||||||
self.set_inboxCount(state.inbox_count)
|
self.set_inboxCount(state.inbox_count)
|
||||||
for mail in self.queryreturn:
|
for mail in self.queryreturn:
|
||||||
# third_text = mail[3].replace('\n', ' ')
|
# third_text = mail[3].replace('\n', ' ')
|
||||||
body = mail[3].decode() if isinstance(mail[3],bytes) else mail[3]
|
body = mail[3].decode() if isinstance(mail[3], bytes) else mail[3]
|
||||||
subject = mail[5].decode() if isinstance(mail[5],bytes) else mail[5]
|
subject = mail[5].decode() if isinstance(mail[5], bytes) else mail[5]
|
||||||
data.append({
|
data.append({
|
||||||
'text': mail[4].strip(),
|
'text': mail[4].strip(),
|
||||||
'secondary_text': (subject[:50] + '........' if len(
|
'secondary_text': (subject[:50] + '........' if len(
|
||||||
subject) >= 50 else (subject + ',' + body)[0:50] + '........').replace('\t', '').replace(' ', ''),
|
subject) >= 50 else (subject + ',' + body)[0:50] + '........').replace(
|
||||||
|
'\t', '').replace(' ', ''),
|
||||||
'msgid': mail[1], 'received': mail[6]})
|
'msgid': mail[1], 'received': mail[6]})
|
||||||
|
|
||||||
self.has_refreshed = True
|
self.has_refreshed = True
|
||||||
|
@ -256,12 +259,12 @@ class Inbox(Screen):
|
||||||
self.inboxDataQuery('toaddress', where, what, total_message, 5)
|
self.inboxDataQuery('toaddress', where, what, total_message, 5)
|
||||||
for mail in self.queryreturn:
|
for mail in self.queryreturn:
|
||||||
# third_text = mail[3].replace('\n', ' ')
|
# third_text = mail[3].replace('\n', ' ')
|
||||||
subject = mail[3].decode() if isinstance(mail[3],bytes) else mail[3]
|
subject = mail[3].decode() if isinstance(mail[3], bytes) else mail[3]
|
||||||
body = mail[5].decode() if isinstance(mail[5],bytes) else mail[5]
|
body = mail[5].decode() if isinstance(mail[5], bytes) else mail[5]
|
||||||
data.append({
|
data.append({
|
||||||
'text': mail[4].strip(),
|
'text': mail[4].strip(),
|
||||||
'secondary_text': body[:50] + '........' if len(
|
'secondary_text': body[:50] + '........' if len(
|
||||||
body) >= 50 else (body + ',' +subject.replace(
|
body) >= 50 else (body + ',' + subject.replace(
|
||||||
'\n', ''))[0:50] + '........',
|
'\n', ''))[0:50] + '........',
|
||||||
'msgid': mail[1]})
|
'msgid': mail[1]})
|
||||||
self.set_mdList(data)
|
self.set_mdList(data)
|
||||||
|
@ -332,6 +335,7 @@ class Inbox(Screen):
|
||||||
|
|
||||||
|
|
||||||
class CustomTwoLineAvatarIconListItem(TwoLineAvatarIconListItem):
|
class CustomTwoLineAvatarIconListItem(TwoLineAvatarIconListItem):
|
||||||
|
"""Custom Two Line Avatar Icon List"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -406,13 +410,15 @@ class MyAddress(Screen):
|
||||||
meny.bind(on_press=partial(
|
meny.bind(on_press=partial(
|
||||||
self.myadd_detail, item['secondary_text'], item['text']))
|
self.myadd_detail, item['secondary_text'], item['text']))
|
||||||
if state.association == item['secondary_text']:
|
if state.association == item['secondary_text']:
|
||||||
meny.add_widget(BadgeText(size_hint= (None, None),
|
meny.add_widget(
|
||||||
|
BadgeText(
|
||||||
|
size_hint=(None, None),
|
||||||
text='Active', halign='right',
|
text='Active', halign='right',
|
||||||
font_style='Body1', size= [50,60],
|
font_style='Body1', size=[50, 60],
|
||||||
theme_text_color='Custom',
|
theme_text_color='Custom',
|
||||||
text_color=NavigateApp().theme_cls.primary_color))
|
text_color=NavigateApp().theme_cls.primary_color))
|
||||||
else:
|
else:
|
||||||
meny.add_widget(ToggleBtn(active = True if is_enable == 'true' else False))
|
meny.add_widget(ToggleBtn(active=True if is_enable == 'true' else False))
|
||||||
# carousel = Carousel(direction='right')
|
# carousel = Carousel(direction='right')
|
||||||
# carousel.height = meny.height
|
# carousel.height = meny.height
|
||||||
# carousel.size_hint_y = None
|
# carousel.size_hint_y = None
|
||||||
|
@ -495,7 +501,6 @@ class MyAddress(Screen):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def disableAddress(self, address, instance):
|
def disableAddress(self, address, instance):
|
||||||
"""This method is use for disabling address"""
|
"""This method is use for disabling address"""
|
||||||
BMConfigParser().set(str(address), 'enabled', 'false')
|
BMConfigParser().set(str(address), 'enabled', 'false')
|
||||||
|
@ -845,7 +850,7 @@ class MyTextInput(TextInput):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
"""Getting Text Input."""
|
"""Getting Text Input."""
|
||||||
super(MyTextInput, self).__init__(**kwargs)
|
super(MyTextInput, self).__init__(**kwargs)
|
||||||
self.__lineBreak__=0
|
self.__lineBreak__ = 0
|
||||||
|
|
||||||
def on_text(self, instance, value):
|
def on_text(self, instance, value):
|
||||||
"""Find all the occurrence of the word"""
|
"""Find all the occurrence of the word"""
|
||||||
|
@ -888,20 +893,21 @@ class Payment(Screen):
|
||||||
state.kivyapp.root.ids.sc18.ids.cred.text = '{0}'.format(
|
state.kivyapp.root.ids.sc18.ids.cred.text = '{0}'.format(
|
||||||
state.availabe_credit)
|
state.availabe_credit)
|
||||||
|
|
||||||
def move_to_pay_option(self, amount):
|
def move_to_pay_option(self, amount): # pylint: disable=no-self-use
|
||||||
|
"""Option move to pay"""
|
||||||
state.kivyapp.set_toolbar_for_QrCode()
|
state.kivyapp.set_toolbar_for_QrCode()
|
||||||
|
|
||||||
|
|
||||||
class Credits(Screen):
|
class Credits(Screen):
|
||||||
"""Credits Method"""
|
"""Credits Method"""
|
||||||
|
|
||||||
available_credits = StringProperty(
|
available_credits = StringProperty('{0}'.format('€ 0'))
|
||||||
'{0}'.format('€ 0'))
|
|
||||||
|
|
||||||
|
|
||||||
class Login(Screen):
|
class Login(Screen):
|
||||||
"""Login Screeen"""
|
"""Login Screeen"""
|
||||||
log_text1 = ('You may generate addresses by using either random numbers'
|
log_text1 = (
|
||||||
|
'You may generate addresses by using either random numbers'
|
||||||
' or by using a passphrase If you use a passphrase, the address'
|
' or by using a passphrase If you use a passphrase, the address'
|
||||||
' is called a deterministic; address The Random Number option is'
|
' is called a deterministic; address The Random Number option is'
|
||||||
' selected by default but deterministic addresses have several pros'
|
' selected by default but deterministic addresses have several pros'
|
||||||
|
@ -1058,7 +1064,8 @@ class Sent(Screen):
|
||||||
data.append({
|
data.append({
|
||||||
'text': mail[1].strip(),
|
'text': mail[1].strip(),
|
||||||
'secondary_text': (mail[2][:50] + '........' if len(
|
'secondary_text': (mail[2][:50] + '........' if len(
|
||||||
mail[2]) >= 50 else (mail[2] + ',' + mail[3])[0:50] + '........').replace('\t', '').replace(' ', ''),
|
mail[2]) >= 50 else (mail[2] + ',' + mail[3])[0:50] + '........').replace(
|
||||||
|
'\t', '').replace(' ', ''),
|
||||||
'ackdata': mail[5], 'senttime': mail[6]},)
|
'ackdata': mail[5], 'senttime': mail[6]},)
|
||||||
self.set_mdlist(data, 0)
|
self.set_mdlist(data, 0)
|
||||||
self.has_refreshed = True
|
self.has_refreshed = True
|
||||||
|
@ -1094,8 +1101,7 @@ class Sent(Screen):
|
||||||
meny = TwoLineAvatarIconListItem(
|
meny = TwoLineAvatarIconListItem(
|
||||||
text=item['text'], secondary_text=item['secondary_text'],
|
text=item['text'], secondary_text=item['secondary_text'],
|
||||||
theme_text_color='Custom',
|
theme_text_color='Custom',
|
||||||
text_color=NavigateApp().theme_cls.primary_color
|
text_color=NavigateApp().theme_cls.primary_color)
|
||||||
)
|
|
||||||
meny.add_widget(AvatarSampleWidget(
|
meny.add_widget(AvatarSampleWidget(
|
||||||
source='./images/text_images/{}.png'.format(
|
source='./images/text_images/{}.png'.format(
|
||||||
avatarImageFirstLetter(item['secondary_text'].strip()))))
|
avatarImageFirstLetter(item['secondary_text'].strip()))))
|
||||||
|
@ -1147,7 +1153,8 @@ class Sent(Screen):
|
||||||
data.append({
|
data.append({
|
||||||
'text': mail[1].strip(),
|
'text': mail[1].strip(),
|
||||||
'secondary_text': (mail[2][:50] + '........' if len(
|
'secondary_text': (mail[2][:50] + '........' if len(
|
||||||
mail[2]) >= 50 else (mail[2] + ',' + mail[3])[0:50] + '........').replace('\t', '').replace(' ', ''),
|
mail[2]) >= 50 else (mail[2] + ',' + mail[3])[0:50] + '........').replace(
|
||||||
|
'\t', '').replace(' ', ''),
|
||||||
'ackdata': mail[5], 'senttime': mail[6]})
|
'ackdata': mail[5], 'senttime': mail[6]})
|
||||||
self.set_mdlist(data, total_sent - 1)
|
self.set_mdlist(data, total_sent - 1)
|
||||||
if state.msg_counter_objs and state.association == (
|
if state.msg_counter_objs and state.association == (
|
||||||
|
@ -1305,8 +1312,8 @@ class Trash(Screen):
|
||||||
"""This method is used to create the mdlist"""
|
"""This method is used to create the mdlist"""
|
||||||
total_trash_msg = len(self.ids.ml.children)
|
total_trash_msg = len(self.ids.ml.children)
|
||||||
for item in self.trash_messages:
|
for item in self.trash_messages:
|
||||||
subject = item[2].decode() if isinstance(item[2],bytes) else item[2]
|
subject = item[2].decode() if isinstance(item[2], bytes) else item[2]
|
||||||
body = item[3].decode() if isinstance(item[3],bytes) else item[3]
|
body = item[3].decode() if isinstance(item[3], bytes) else item[3]
|
||||||
meny = TwoLineAvatarIconListItem(
|
meny = TwoLineAvatarIconListItem(
|
||||||
text=item[1],
|
text=item[1],
|
||||||
secondary_text=(item[2][:50] + '........' if len(
|
secondary_text=(item[2][:50] + '........' if len(
|
||||||
|
@ -1424,8 +1431,9 @@ class Setting(Screen):
|
||||||
"""Setting the Screen components"""
|
"""Setting the Screen components"""
|
||||||
exp_text = "By default, if you send a message to someone and he is offline for more than two days, Bitmessage will\
|
exp_text = "By default, if you send a message to someone and he is offline for more than two days, Bitmessage will\
|
||||||
send the message again after an additional two days. This will be continued with exponential backoff\
|
send the message again after an additional two days. This will be continued with exponential backoff\
|
||||||
forever; messages will be resent after 5, 10, 20 days ect. until the receiver acknowledges them. Here you\
|
forever; messages will be resent after 5, 10, 20 days ect. until the receiver acknowledges them.\
|
||||||
may change that behavior by having Bitmessage give up after a certain number of days or months."
|
Here you may change that behavior by having Bitmessage give up after a certain number of days \
|
||||||
|
or months."
|
||||||
|
|
||||||
|
|
||||||
class NavigateApp(MDApp):
|
class NavigateApp(MDApp):
|
||||||
|
@ -1583,7 +1591,7 @@ class NavigateApp(MDApp):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def on_key(self, window, key, *args):
|
def on_key(self, window, key, *args):
|
||||||
# pylint: disable=inconsistent-return-statements
|
# pylint: disable=inconsistent-return-statements, too-many-branches
|
||||||
"""Method is used for going on previous screen"""
|
"""Method is used for going on previous screen"""
|
||||||
if key == 27:
|
if key == 27:
|
||||||
if state.in_search_mode and self.root.ids.scr_mngr.current != (
|
if state.in_search_mode and self.root.ids.scr_mngr.current != (
|
||||||
|
@ -1687,7 +1695,6 @@ class NavigateApp(MDApp):
|
||||||
state.in_composer = True
|
state.in_composer = True
|
||||||
state.in_sent_method = False
|
state.in_sent_method = False
|
||||||
|
|
||||||
|
|
||||||
def set_navbar_for_composer(self):
|
def set_navbar_for_composer(self):
|
||||||
"""Clearing toolbar data when composer open"""
|
"""Clearing toolbar data when composer open"""
|
||||||
self.root.ids.toolbar.left_action_items = [
|
self.root.ids.toolbar.left_action_items = [
|
||||||
|
@ -1936,7 +1943,6 @@ class NavigateApp(MDApp):
|
||||||
def file_manager_open(self):
|
def file_manager_open(self):
|
||||||
"""This method open the file manager of local system"""
|
"""This method open the file manager of local system"""
|
||||||
from kivymd.uix.filemanager import MDFileManager
|
from kivymd.uix.filemanager import MDFileManager
|
||||||
from kivymd.uix.dialog import MDDialog
|
|
||||||
|
|
||||||
self.manager = ModalView(size_hint=(1, 1), auto_dismiss=False)
|
self.manager = ModalView(size_hint=(1, 1), auto_dismiss=False)
|
||||||
self.file_manager = MDFileManager(
|
self.file_manager = MDFileManager(
|
||||||
|
@ -1955,7 +1961,7 @@ class NavigateApp(MDApp):
|
||||||
from PIL import Image as PilImage
|
from PIL import Image as PilImage
|
||||||
if not os.path.exists('./images/default_identicon/'):
|
if not os.path.exists('./images/default_identicon/'):
|
||||||
os.makedirs('./images/default_identicon/')
|
os.makedirs('./images/default_identicon/')
|
||||||
newImg = PilImage.open(path).resize((300,300))
|
newImg = PilImage.open(path).resize((300, 300))
|
||||||
newImg.save('./images/default_identicon/{0}.png'.format(state.association))
|
newImg.save('./images/default_identicon/{0}.png'.format(state.association))
|
||||||
self.load_selected_Image(state.association)
|
self.load_selected_Image(state.association)
|
||||||
self.exit_manager()
|
self.exit_manager()
|
||||||
|
@ -1972,11 +1978,11 @@ class NavigateApp(MDApp):
|
||||||
top_box_obj = self.root.ids.content_drawer.ids.top_box.children[0]
|
top_box_obj = self.root.ids.content_drawer.ids.top_box.children[0]
|
||||||
# spinner_img_obj = self.root.ids.content_drawer.ids.btn.children[1]
|
# spinner_img_obj = self.root.ids.content_drawer.ids.btn.children[1]
|
||||||
# spinner_img_obj.source = top_box_obj.source ='./images/default_identicon/{0}.png'.format(curerentAddr)
|
# spinner_img_obj.source = top_box_obj.source ='./images/default_identicon/{0}.png'.format(curerentAddr)
|
||||||
top_box_obj.source ='./images/default_identicon/{0}.png'.format(curerentAddr)
|
top_box_obj.source = './images/default_identicon/{0}.png'.format(curerentAddr)
|
||||||
top_box_obj.reload()
|
top_box_obj.reload()
|
||||||
# spinner_img_obj.reload()
|
# spinner_img_obj.reload()
|
||||||
|
|
||||||
def copy_composer_text(self, text):
|
def copy_composer_text(self, text): # pylint: disable=no-self-use
|
||||||
"""Copy the data from mail detail page"""
|
"""Copy the data from mail detail page"""
|
||||||
Clipboard.copy(text)
|
Clipboard.copy(text)
|
||||||
toast('Copied')
|
toast('Copied')
|
||||||
|
@ -2115,12 +2121,6 @@ class IconRightSampleWidget(IRightBodyTouch, MDIconButton):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class IconRightSampleWidget(IRightBodyTouch, MDCheckbox):
|
|
||||||
"""Right icon sample widget"""
|
|
||||||
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class ToggleBtn(IRightBodyTouch, MDSwitch):
|
class ToggleBtn(IRightBodyTouch, MDSwitch):
|
||||||
"""Right toggle button widget"""
|
"""Right toggle button widget"""
|
||||||
pass
|
pass
|
||||||
|
@ -2132,7 +2132,7 @@ class CheckboxLeftSampleWidget(ILeftBodyTouch, MDCheckbox):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class MailDetail(Screen):
|
class MailDetail(Screen): # pylint: disable=too-many-instance-attributes
|
||||||
"""MailDetail Screen uses to show the detail of mails"""
|
"""MailDetail Screen uses to show the detail of mails"""
|
||||||
|
|
||||||
to_addr = StringProperty()
|
to_addr = StringProperty()
|
||||||
|
@ -2169,8 +2169,8 @@ class MailDetail(Screen):
|
||||||
|
|
||||||
def assign_mail_details(self, data):
|
def assign_mail_details(self, data):
|
||||||
"""Assigning mail details"""
|
"""Assigning mail details"""
|
||||||
subject = data[0][2].decode() if isinstance(data[0][2],bytes) else data[0][2]
|
subject = data[0][2].decode() if isinstance(data[0][2], bytes) else data[0][2]
|
||||||
body = data[0][3].decode() if isinstance(data[0][2],bytes) else data[0][3]
|
body = data[0][3].decode() if isinstance(data[0][2], bytes) else data[0][3]
|
||||||
self.to_addr = data[0][0] if len(data[0][0]) > 4 else ' '
|
self.to_addr = data[0][0] if len(data[0][0]) > 4 else ' '
|
||||||
self.from_addr = data[0][1]
|
self.from_addr = data[0][1]
|
||||||
|
|
||||||
|
@ -2180,7 +2180,7 @@ class MailDetail(Screen):
|
||||||
if len(data[0]) == 7:
|
if len(data[0]) == 7:
|
||||||
self.status = data[0][4]
|
self.status = data[0][4]
|
||||||
self.time_tag = ShowTimeHistoy(data[0][4]) if state.detailPageType == 'inbox' else ShowTimeHistoy(data[0][6])
|
self.time_tag = ShowTimeHistoy(data[0][4]) if state.detailPageType == 'inbox' else ShowTimeHistoy(data[0][6])
|
||||||
self.avatarImg= './images/avatar.png' if state.detailPageType == 'draft' else (
|
self.avatarImg = './images/avatar.png' if state.detailPageType == 'draft' else (
|
||||||
'./images/text_images/{0}.png'.format(avatarImageFirstLetter(self.subject.strip())))
|
'./images/text_images/{0}.png'.format(avatarImageFirstLetter(self.subject.strip())))
|
||||||
self.timeinseconds = data[0][4] if state.detailPageType == 'inbox' else data[0][6]
|
self.timeinseconds = data[0][4] if state.detailPageType == 'inbox' else data[0][6]
|
||||||
|
|
||||||
|
@ -2282,6 +2282,7 @@ class MailDetail(Screen):
|
||||||
navApp.set_navbar_for_composer()
|
navApp.set_navbar_for_composer()
|
||||||
|
|
||||||
def detailedPopup(self):
|
def detailedPopup(self):
|
||||||
|
"""Detailed popup"""
|
||||||
obj = SenderDetailPopup()
|
obj = SenderDetailPopup()
|
||||||
obj.open()
|
obj.open()
|
||||||
arg = (self.to_addr, self.from_addr, self.timeinseconds)
|
arg = (self.to_addr, self.from_addr, self.timeinseconds)
|
||||||
|
@ -2313,7 +2314,7 @@ class MyaddDetailPopup(Popup):
|
||||||
state.kivyapp.set_navbar_for_composer()
|
state.kivyapp.set_navbar_for_composer()
|
||||||
try:
|
try:
|
||||||
window_obj = self.parent.children[2].ids
|
window_obj = self.parent.children[2].ids
|
||||||
except Exception as e:
|
except Exception:
|
||||||
window_obj = self.parent.children[1].ids
|
window_obj = self.parent.children[1].ids
|
||||||
window_obj.sc3.children[1].ids.ti.text = self.address
|
window_obj.sc3.children[1].ids.ti.text = self.address
|
||||||
window_obj.sc3.children[1].ids.btn.text = self.address
|
window_obj.sc3.children[1].ids.btn.text = self.address
|
||||||
|
@ -2367,7 +2368,7 @@ class AddbookDetailPopup(Popup):
|
||||||
state.kivyapp.set_navbar_for_composer()
|
state.kivyapp.set_navbar_for_composer()
|
||||||
try:
|
try:
|
||||||
window_obj = self.parent.children[2].ids
|
window_obj = self.parent.children[2].ids
|
||||||
except Exception as e:
|
except Exception:
|
||||||
window_obj = self.parent.children[1].ids
|
window_obj = self.parent.children[1].ids
|
||||||
window_obj.sc3.children[1].ids.txt_input.text = self.address
|
window_obj.sc3.children[1].ids.txt_input.text = self.address
|
||||||
window_obj.sc3.children[1].ids.ti.text = ''
|
window_obj.sc3.children[1].ids.ti.text = ''
|
||||||
|
@ -2604,7 +2605,8 @@ class Draft(Screen):
|
||||||
encoding,
|
encoding,
|
||||||
BMConfigParser().safeGetInt('bitmessagesettings', 'ttl'))
|
BMConfigParser().safeGetInt('bitmessagesettings', 'ttl'))
|
||||||
state.msg_counter_objs = src_object.children[2].children[0].ids
|
state.msg_counter_objs = src_object.children[2].children[0].ids
|
||||||
state.draft_count = str(int(state.draft_count) + 1) if state.association == fromAddress else state.draft_count
|
state.draft_count = str(int(state.draft_count) + 1) \
|
||||||
|
if state.association == fromAddress else state.draft_count
|
||||||
src_object.ids.sc16.clear_widgets()
|
src_object.ids.sc16.clear_widgets()
|
||||||
src_object.ids.sc16.add_widget(Draft())
|
src_object.ids.sc16.add_widget(Draft())
|
||||||
toast('Save draft')
|
toast('Save draft')
|
||||||
|
@ -2688,8 +2690,8 @@ class Allmails(Screen):
|
||||||
"""This method is used to create mdList for allmaills"""
|
"""This method is used to create mdList for allmaills"""
|
||||||
data_exist = len(self.ids.ml.children)
|
data_exist = len(self.ids.ml.children)
|
||||||
for item in self.all_mails:
|
for item in self.all_mails:
|
||||||
body = item[3].decode() if isinstance(item[3],bytes) else item[3]
|
body = item[3].decode() if isinstance(item[3], bytes) else item[3]
|
||||||
subject = item[2].decode() if isinstance(item[2],bytes) else item[2]
|
subject = item[2].decode() if isinstance(item[2], bytes) else item[2]
|
||||||
meny = TwoLineAvatarIconListItem(
|
meny = TwoLineAvatarIconListItem(
|
||||||
text=item[1],
|
text=item[1],
|
||||||
secondary_text=(subject[:50] + '........' if len(
|
secondary_text=(subject[:50] + '........' if len(
|
||||||
|
@ -2864,6 +2866,7 @@ class NavigationItem(OneLineAvatarIconListItem):
|
||||||
active = BooleanProperty(False)
|
active = BooleanProperty(False)
|
||||||
|
|
||||||
def currentlyActive(self):
|
def currentlyActive(self):
|
||||||
|
"""Currenly active"""
|
||||||
for nav_obj in self.parent.children:
|
for nav_obj in self.parent.children:
|
||||||
nav_obj.active = False
|
nav_obj.active = False
|
||||||
self.active = True
|
self.active = True
|
||||||
|
@ -2927,22 +2930,23 @@ class SenderDetailPopup(Popup):
|
||||||
super(SenderDetailPopup, self).__init__(**kwargs)
|
super(SenderDetailPopup, self).__init__(**kwargs)
|
||||||
|
|
||||||
def assignDetail(self, to_addr, from_addr, timeinseconds):
|
def assignDetail(self, to_addr, from_addr, timeinseconds):
|
||||||
|
"""Detailes assigned"""
|
||||||
self.to_addr = to_addr
|
self.to_addr = to_addr
|
||||||
self.from_addr = from_addr
|
self.from_addr = from_addr
|
||||||
time_obj = datetime.fromtimestamp(int(timeinseconds))
|
time_obj = datetime.fromtimestamp(int(timeinseconds))
|
||||||
self.time_tag = time_obj.strftime("%d %b %Y, %I:%M %p")
|
self.time_tag = time_obj.strftime("%d %b %Y, %I:%M %p")
|
||||||
pop_height = 1.2*(self.ids.sd_label.height+self.ids.sd_btn.children[0].height)
|
pop_height = 1.2 * (self.ids.sd_label.height + self.ids.sd_btn.children[0].height)
|
||||||
if len(to_addr) > 3:
|
if len(to_addr) > 3:
|
||||||
self.height = 0
|
self.height = 0
|
||||||
self.height = pop_height
|
self.height = pop_height
|
||||||
self.ids.to_addId.size_hint_y = None
|
self.ids.to_addId.size_hint_y = None
|
||||||
self.ids.to_addId.height= 50
|
self.ids.to_addId.height = 50
|
||||||
frmaddbox = ToAddrBoxlayout()
|
frmaddbox = ToAddrBoxlayout()
|
||||||
frmaddbox.set_toAddress(to_addr)
|
frmaddbox.set_toAddress(to_addr)
|
||||||
self.ids.to_addId.add_widget(frmaddbox)
|
self.ids.to_addId.add_widget(frmaddbox)
|
||||||
else:
|
else:
|
||||||
self.height = 0
|
self.height = 0
|
||||||
self.height = pop_height/1.5
|
self.height = pop_height / 1.5
|
||||||
|
|
||||||
|
|
||||||
class OneLineListTitle(OneLineListItem):
|
class OneLineListTitle(OneLineListItem):
|
||||||
|
@ -2951,6 +2955,7 @@ class OneLineListTitle(OneLineListItem):
|
||||||
long_press_time = NumericProperty(1)
|
long_press_time = NumericProperty(1)
|
||||||
|
|
||||||
def on_state(self, instance, value):
|
def on_state(self, instance, value):
|
||||||
|
"""On state"""
|
||||||
if value == 'down':
|
if value == 'down':
|
||||||
lpt = self.long_press_time
|
lpt = self.long_press_time
|
||||||
self._clockev = Clock.schedule_once(self._do_long_press, lpt)
|
self._clockev = Clock.schedule_once(self._do_long_press, lpt)
|
||||||
|
@ -2958,9 +2963,11 @@ class OneLineListTitle(OneLineListItem):
|
||||||
self._clockev.cancel()
|
self._clockev.cancel()
|
||||||
|
|
||||||
def _do_long_press(self, dt):
|
def _do_long_press(self, dt):
|
||||||
|
"""Do long press"""
|
||||||
self.dispatch('on_long_press')
|
self.dispatch('on_long_press')
|
||||||
|
|
||||||
def on_long_press(self, *largs):
|
def on_long_press(self, *largs):
|
||||||
|
"""On long press"""
|
||||||
self.copymessageTitle(self.text)
|
self.copymessageTitle(self.text)
|
||||||
|
|
||||||
def copymessageTitle(self, text):
|
def copymessageTitle(self, text):
|
||||||
|
@ -2995,4 +3002,5 @@ class PaymentMethods(Screen):
|
||||||
"""PaymentMethods Screen show widgets of page"""
|
"""PaymentMethods Screen show widgets of page"""
|
||||||
|
|
||||||
def redirect_on_web(self, instance):
|
def redirect_on_web(self, instance):
|
||||||
|
"""Redirect on web"""
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -3,7 +3,6 @@ BMConfigParser class definition and default configuration settings
|
||||||
"""
|
"""
|
||||||
# pylint: disable=no-self-use, arguments-differ
|
# pylint: disable=no-self-use, arguments-differ
|
||||||
import configparser
|
import configparser
|
||||||
import shutil
|
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
|
@ -439,7 +439,7 @@ class objectProcessor(threading.Thread):
|
||||||
return
|
return
|
||||||
|
|
||||||
# Let us try to decrypt the pubkey
|
# Let us try to decrypt the pubkey
|
||||||
toAddress, _ = state.neededPubkeys[bytes(tag)] #check with py2
|
toAddress, _ = state.neededPubkeys[bytes(tag)] # check with py2
|
||||||
if protocol.decryptAndCheckPubkeyPayload(bytes(data), toAddress) == \
|
if protocol.decryptAndCheckPubkeyPayload(bytes(data), toAddress) == \
|
||||||
'successful':
|
'successful':
|
||||||
# At this point we know that we have been waiting on this
|
# At this point we know that we have been waiting on this
|
||||||
|
|
|
@ -1158,7 +1158,7 @@ class singleWorker(StoppableThread):
|
||||||
fullAckPayload = self.generateFullAckMessage(
|
fullAckPayload = self.generateFullAckMessage(
|
||||||
ackdata, toStreamNumber, TTL)
|
ackdata, toStreamNumber, TTL)
|
||||||
payload += encodeVarint(len(fullAckPayload))
|
payload += encodeVarint(len(fullAckPayload))
|
||||||
payload += fullAckPayload if isinstance(fullAckPayload,bytes) else fullAckPayload.encode()
|
payload += fullAckPayload if isinstance(fullAckPayload, bytes) else fullAckPayload.encode()
|
||||||
dataToSign = pack('>Q', embeddedTime) + '\x00\x00\x00\x02'.encode() + \
|
dataToSign = pack('>Q', embeddedTime) + '\x00\x00\x00\x02'.encode() + \
|
||||||
encodeVarint(1) + encodeVarint(toStreamNumber) + payload
|
encodeVarint(1) + encodeVarint(toStreamNumber) + payload
|
||||||
signature = highlevelcrypto.sign(dataToSign, privSigningKeyHex)
|
signature = highlevelcrypto.sign(dataToSign, privSigningKeyHex)
|
||||||
|
@ -1201,11 +1201,11 @@ class singleWorker(StoppableThread):
|
||||||
self.logger.info(
|
self.logger.info(
|
||||||
'(For msg message) Doing proof of work. Total required'
|
'(For msg message) Doing proof of work. Total required'
|
||||||
' difficulty: {}. Required small message difficulty: {}.'.format
|
' difficulty: {}. Required small message difficulty: {}.'.format
|
||||||
(float(requiredAverageProofOfWorkNonceTrialsPerByte) /
|
(
|
||||||
|
float(requiredAverageProofOfWorkNonceTrialsPerByte) /
|
||||||
defaults.networkDefaultProofOfWorkNonceTrialsPerByte,
|
defaults.networkDefaultProofOfWorkNonceTrialsPerByte,
|
||||||
float(requiredPayloadLengthExtraBytes) /
|
float(requiredPayloadLengthExtraBytes) /
|
||||||
defaults.networkDefaultPayloadLengthExtraBytes)
|
defaults.networkDefaultPayloadLengthExtraBytes))
|
||||||
)
|
|
||||||
|
|
||||||
powStartTime = time.time()
|
powStartTime = time.time()
|
||||||
initialHash = hashlib.sha512(encryptedPayload).digest()
|
initialHash = hashlib.sha512(encryptedPayload).digest()
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
Message encoding end decoding functions
|
Message encoding end decoding functions
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import string
|
|
||||||
import zlib
|
import zlib
|
||||||
|
|
||||||
import messagetypes
|
import messagetypes
|
||||||
|
|
|
@ -8,7 +8,7 @@ from singleton import Singleton
|
||||||
|
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class Inventory():
|
class Inventory(object):
|
||||||
"""
|
"""
|
||||||
Inventory singleton class which uses storage backends
|
Inventory singleton class which uses storage backends
|
||||||
to manage the inventory.
|
to manage the inventory.
|
||||||
|
|
|
@ -15,7 +15,7 @@ class Message(MsgBase):
|
||||||
# UTF-8 and variable type validator
|
# UTF-8 and variable type validator
|
||||||
if isinstance(data["subject"], str):
|
if isinstance(data["subject"], str):
|
||||||
# Unicode is depreciated
|
# Unicode is depreciated
|
||||||
self.subject =data["subject"]
|
self.subject = data["subject"]
|
||||||
else:
|
else:
|
||||||
# Unicode is depreciated
|
# Unicode is depreciated
|
||||||
self.subject = str(data["subject"])
|
self.subject = str(data["subject"])
|
||||||
|
|
|
@ -114,6 +114,7 @@ class BMObject(object): # pylint: disable=too-many-instance-attributes
|
||||||
or advertise it unnecessarily)
|
or advertise it unnecessarily)
|
||||||
"""
|
"""
|
||||||
# if it's a stem duplicate, pretend we don't have it
|
# if it's a stem duplicate, pretend we don't have it
|
||||||
|
# pylint: disable=protected-access
|
||||||
if Dandelion().hasHash(self.inventoryHash):
|
if Dandelion().hasHash(self.inventoryHash):
|
||||||
return
|
return
|
||||||
if self.inventoryHash in Inventory():
|
if self.inventoryHash in Inventory():
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"""
|
"""
|
||||||
Bitmessage Protocol
|
Bitmessage Protocol
|
||||||
"""
|
"""
|
||||||
# pylint: disable=attribute-defined-outside-init, too-few-public-methods, logging-format-interpolation
|
# pylint: disable=attribute-defined-outside-init,too-few-public-methods,logging-format-interpolation,protected-access
|
||||||
import base64
|
import base64
|
||||||
import hashlib
|
import hashlib
|
||||||
import logging
|
import logging
|
||||||
|
@ -31,7 +31,7 @@ from network.dandelion import Dandelion
|
||||||
from network.proxy import ProxyError
|
from network.proxy import ProxyError
|
||||||
from network.objectracker import missingObjects, ObjectTracker
|
from network.objectracker import missingObjects, ObjectTracker
|
||||||
from network.node import Node, Peer
|
from network.node import Node, Peer
|
||||||
from queues import objectProcessorQueue, portCheckerQueue, invQueue, addrQueue
|
from queues import objectProcessorQueue, portCheckerQueue, invQueue
|
||||||
from network.randomtrackingdict import RandomTrackingDict
|
from network.randomtrackingdict import RandomTrackingDict
|
||||||
|
|
||||||
logger = logging.getLogger('default')
|
logger = logging.getLogger('default')
|
||||||
|
|
|
@ -40,7 +40,7 @@ class DownloadThread(StoppableThread):
|
||||||
del missingObjects[i]
|
del missingObjects[i]
|
||||||
self.lastCleaned = time.time()
|
self.lastCleaned = time.time()
|
||||||
|
|
||||||
def run(self):
|
def run(self): # pylint: disable=protected-access
|
||||||
while not self._stopped:
|
while not self._stopped:
|
||||||
requested = 0
|
requested = 0
|
||||||
connections = BMConnectionPool().establishedConnections()
|
connections = BMConnectionPool().establishedConnections()
|
||||||
|
|
|
@ -92,13 +92,13 @@ class InvThread(StoppableThread):
|
||||||
connection.append_write_buf(protocol.CreatePacket(
|
connection.append_write_buf(protocol.CreatePacket(
|
||||||
'inv',
|
'inv',
|
||||||
addresses.encodeVarint(
|
addresses.encodeVarint(
|
||||||
len(fluffs)) + ('').encode().join([x for x in fluffs]))) #compare result with python2
|
len(fluffs)) + ('').encode().join([x for x in fluffs]))) # compare result with python2
|
||||||
if stems:
|
if stems:
|
||||||
random.shuffle(stems)
|
random.shuffle(stems)
|
||||||
connection.append_write_buf(protocol.CreatePacket(
|
connection.append_write_buf(protocol.CreatePacket(
|
||||||
'dinv',
|
'dinv',
|
||||||
addresses.encodeVarint(
|
addresses.encodeVarint(
|
||||||
len(stems)) + ('').encode().join([x for x in stems]))) #compare result with python2
|
len(stems)) + ('').encode().join([x for x in stems]))) # compare result with python2
|
||||||
|
|
||||||
invQueue.iterate()
|
invQueue.iterate()
|
||||||
for _ in range(len(chunk)):
|
for _ in range(len(chunk)):
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"""
|
"""
|
||||||
TCP protocol handler
|
TCP protocol handler
|
||||||
"""
|
"""
|
||||||
# pylint: disable=too-many-ancestors
|
# pylint: disable=too-many-ancestors, protected-access
|
||||||
import logging
|
import logging
|
||||||
import math
|
import math
|
||||||
import random
|
import random
|
||||||
|
|
|
@ -110,7 +110,6 @@ def _doFastPoW(target, initialHash):
|
||||||
time.sleep(0.2)
|
time.sleep(0.2)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def _doCPoW(target, initialHash):
|
def _doCPoW(target, initialHash):
|
||||||
out_h = ctypes.pointer(ctypes.create_string_buffer(initialHash, 64))
|
out_h = ctypes.pointer(ctypes.create_string_buffer(initialHash, 64))
|
||||||
out_m = ctypes.c_ulonglong(target)
|
out_m = ctypes.c_ulonglong(target)
|
||||||
|
|
|
@ -289,7 +289,7 @@ def isProofOfWorkSufficient(
|
||||||
|
|
||||||
def CreatePacket(command, payload=''):
|
def CreatePacket(command, payload=''):
|
||||||
"""Construct and return a number of bytes from a payload"""
|
"""Construct and return a number of bytes from a payload"""
|
||||||
payload = payload if type(payload) in [bytes, bytearray,memoryview] else payload.encode()
|
payload = payload if type(payload) in [bytes, bytearray, memoryview] else payload.encode()
|
||||||
payload_length = len(payload)
|
payload_length = len(payload)
|
||||||
checksum = hashlib.sha512(payload).digest()[0:4]
|
checksum = hashlib.sha512(payload).digest()[0:4]
|
||||||
byte = bytearray(Header.size + payload_length)
|
byte = bytearray(Header.size + payload_length)
|
||||||
|
|
|
@ -25,7 +25,6 @@ from addresses import decodeAddress, encodeVarint
|
||||||
from bmconfigparser import BMConfigParser
|
from bmconfigparser import BMConfigParser
|
||||||
from debug import logger
|
from debug import logger
|
||||||
from helper_sql import sqlQuery
|
from helper_sql import sqlQuery
|
||||||
from pyelliptic import arithmetic
|
|
||||||
# pylint: disable=logging-format-interpolation
|
# pylint: disable=logging-format-interpolation
|
||||||
|
|
||||||
verbose = 1
|
verbose = 1
|
||||||
|
|
|
@ -42,7 +42,7 @@ class SqliteInventory(InventoryStorage): # pylint: disable=too-many-ancestors
|
||||||
|
|
||||||
def __getitem__(self, hash_):
|
def __getitem__(self, hash_):
|
||||||
with self.lock:
|
with self.lock:
|
||||||
if isinstance(hash_,memoryview) and bytes(hash_) in self._inventory :
|
if isinstance(hash_, memoryview) and bytes(hash_) in self._inventory:
|
||||||
return self._inventory[bytes(hash_)]
|
return self._inventory[bytes(hash_)]
|
||||||
else:
|
else:
|
||||||
if hash_ in self._inventory:
|
if hash_ in self._inventory:
|
||||||
|
|
Reference in New Issue
Block a user