reworked export format to be more human-readable

This commit is contained in:
Kjistóf 2017-12-02 11:59:59 +01:00
parent b95982818e
commit ee5b0c08c5
1 changed files with 3 additions and 5 deletions

View File

@ -30,14 +30,12 @@ class pow_base:
return int(hexresult, 16) < self._target
def export(self):
return b64encode(str(self.difficulty).encode()
+ b':'
+ self.base).decode()
return str(self.difficulty) + ':' + b64encode(self.base).decode()
@classmethod
def load(cls, export):
difficulty, base = b64decode(export.encode()).split(b':', 1)
return cls(int(difficulty), base)
difficulty, base = export.split(':', 1)
return cls(int(difficulty), b64decode(base.encode()))
class pow_hashlib_base(pow_base):