forked from harmony-community-node/hmybidder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
62 lines (52 loc) · 1.96 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from builtins import object
class NetworkInfo(object):
def __init__(self, epoch_last_block, median_raw_staking, block_number, blocks_to_next_epoch):
self.epoch_last_block = epoch_last_block
self.median_raw_staking = median_raw_staking
self.block_number = block_number
self.blocks_to_next_epoch = blocks_to_next_epoch
def to_dict(self):
return dict(
epoch_last_block = self.epoch_last_block,
median_raw_staking = self.median_raw_staking,
block_number = self.block_number,
blocks_to_next_epoch = self.blocks_to_next_epoch
)
@classmethod
def from_dict(cls, data):
return NetworkInfo(data["epoch_last_block"],
data["median_raw_staking"],
data["block_number"],
data["blocks_to_next_epoch"])
class BlsKey(object):
def __init__(self, blskey, shardId):
self.blskey = blskey
self.shardId = shardId
def to_dict(self):
return dict(
blskey = self.blskey,
shardId = self.shardId
)
@classmethod
def from_dict(cls, data):
return BlsKey(data["blskey"],
data["shardId"])
class ValidatorInfo(object):
def __init__(self, active_status, epos_status, total_delegation, blsKeys):
self.active_status = active_status
self.epos_status = epos_status
self.total_delegation = total_delegation
self.blsKeys = blsKeys
def to_dict(self):
return dict(
active_status = self.active_status,
epos_status = self.epos_status,
total_delegation = self.total_delegation,
blsKeys = self.blsKeys
)
@classmethod
def from_dict(cls, data):
return ValidatorInfo(data["active_status"],
data["epos_status"],
data["total_delegation"],
data["blsKeys"])