Skip to content

Commit

Permalink
Decode protocol_parameters #28
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kus committed Sep 16, 2020
1 parent 8e6b7fb commit c5c437b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pytezos/rpc/protocol.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pendulum
import bson
from pendulum.parsing.exceptions import ParserError
from datetime import datetime
from itertools import count
Expand Down Expand Up @@ -133,11 +134,17 @@ def level(self) -> int:
return self.metadata()['level']['level']

def cycle(self) -> int:
"""
Get cycle for this block from metadata.
""" Get cycle for this block from metadata.
"""
return self.metadata()['level']['cycle']

def protocol_parameters(self):
""" Get decoded protocol parameters if they do exist in the header
"""
pp = self.header().get('content', {}).get('protocol_parameters')
if pp:
return bson.loads(bytes.fromhex(pp)[4:])


class ContractQuery(RpcQuery, path='/chains/{}/blocks/{}/context/contracts/{}'):

Expand Down

0 comments on commit c5c437b

Please sign in to comment.