Skip to content
Snippets Groups Projects
Commit c60745cf authored by Vincent Texier's avatar Vincent Texier
Browse files

Merge remote-tracking branch 'origin/refactor' into refactor

parents de60e8e6 ce657a82
No related branches found
No related tags found
No related merge requests found
......@@ -9,11 +9,8 @@ from ..key import Base58Encoder
class Document:
def __init__(self, timestamp):
self.timestamp = timestamp
def ts(self):
return "META:TS:{0}".format(self.timestamp)
def __init__(self, version):
self.version = version
def content(self):
return ""
......
......@@ -76,6 +76,66 @@ BOTTOM_SIGNATURE
self.certifications = certifications
self.transactions = transactions
@classmethod
def from_raw(cls, raw):
#TODO : Parsing
lines = raw.splitlines(True)
n = 0
version_re = re.compile("Version: ([0-9]+)\n")
version = version_re.match(lines[n])
n = 1
currency_re = re.compile("Currency: ([0-9a-zA-Z_\-]+)\n"
currency = currency_re.match(lines[n])
n = 2
noonce_re = re.compile("Nonce: ([0-9]+)\n")
noonce = nonce_re.match(lines[n])
n = 3
number_re = re.compile("Number: ([0-9]+)\n")
number = number_re.match(lines[n])
n = 4
powmin_re = re.compile("PoWMin: ([0-9]+)\n")
powmin = powmin.match(lines[n])
n = 5
time_re = re.compile("Time: ([0-9]+)\n")
time = time.match(lines[n])
n = 6
mediantime_re = re.compile("MedianTime: ([0-9]+)\n")
mediantime = mediantime_re.match(line[n])
n = 7
ud_re = re.compile("UniversalDividend: ([0-9]+)\n")
ud = ud_re.match(line[n])
n = 8
issuer_re = re.compile("Issuer: ([1-9A-Za-z][^OIl]{43,45})\n")
issuer = issuer_re.match(line[n])
n = 9
previoushash_re = re.compile("PreviousHash: ([0-9a-fA-F]{5,40})\n")
prev_hash = previoushash_re.match(line[n])
n = 10
previousissuer_re = re.compile("PreviousIssuer: ([1-9A-Za-z][^OIl]{43,45})\n")
prev_issuer = previousissuer_re.match(line[n])
parameters = ""
members_count = ""
identities = ""
joiners = ""
actives = ""
leavers = ""
excluded = ""
certifications = ""
transactions = ""
return cls([])
def content(self):
doc = """
Version: {0}
......
......@@ -13,12 +13,21 @@ class SelfCertification(Document):
def __init__(self, identifier):
self.identifier = identifier
self.timestamp = timestamp
@classmethod
def from_raw(cls, raw):
#TODO : Parsing
return cls()
def ts(self):
return "META:TS:{0}".format(self.timestamp)
def uid(self):
return "UID:{0}".format(self.identifier)
def content(self):
return "{0}\n{1}".format(self.uid(), self.timestamp())
return "{0}\n{1}".format(self.uid(), self.ts())
class Certification(Document):
......@@ -33,8 +42,14 @@ class Certification(Document):
self.selfcert = selfcert
self.blockid = blockid
def timestamp(self):
@classmethod
def from_raw(cls, raw):
#TODO : Parsing
return cls()
def ts(self):
return "META:TS:{0}".format(self.blockid)
def content(self):
return "{0}\n{1}".format(self.selfcert.content(), self.timestamp())
return "{0}\n{1}".format(self.selfcert.content(), self.ts())
......@@ -32,6 +32,14 @@ class Membership(object):
self.userid = userid
self.cert_ts = cert_ts
@classmethod
def from_raw(cls, raw):
#TODO : Parsing
return cls()
def content(self):
return """
Version: {0}
......
......@@ -30,6 +30,11 @@ class Peer(Document):
self.blockid = blockid
self.endpoints = endpoints
@classmethod
def from_raw(cls, raw):
#TODO : Parsing
return cls()
def content(self):
doc = """
Version: {0}
......
......@@ -29,6 +29,11 @@ class Status(Document):
self.sender = sender
self.recipient = recipient
@classmethod
def from_raw(cls, raw):
#TODO : Parsing
return cls()
def content(self):
return '''
Version: {0}
......
......@@ -37,6 +37,11 @@ SIGNATURES
self.outputs = outputs
self.comment = comment
@classmethod
def from_raw(cls, raw):
#TODO : Parsing
return cls()
def content(self):
doc = """
Version: {0}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment