Zeth - Zerocash on Ethereum  0.8
Reference implementation of the Zeth protocol by Clearmatics
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
coordinator.server_state.ServerState Class Reference

Public Member Functions

def __init__ (self, int next_contributor_index, int num_contributors, float next_contributor_deadline)
 
str to_json (self)
 
bool have_all_contributions (self)
 
None received_contribution (self, float next_deadline)
 
bool update (self, float now, float interval)
 

Static Public Member Functions

ServerState from_json (str state_json)
 

Public Attributes

 next_contributor_index
 
 next_contributor_deadline
 

Detailed Description

Current state of the server

Definition at line 14 of file server_state.py.

Constructor & Destructor Documentation

◆ __init__()

def coordinator.server_state.ServerState.__init__ (   self,
int  next_contributor_index,
int  num_contributors,
float  next_contributor_deadline 
)

Definition at line 18 of file server_state.py.

18  def __init__(
19  self,
20  next_contributor_index: int,
21  num_contributors: int,
22  next_contributor_deadline: float):
23  self.next_contributor_index: int = next_contributor_index
24  self.num_contributors: int = num_contributors
25  self.next_contributor_deadline: float = next_contributor_deadline
26  assert self.num_contributors != 0
27 

Member Function Documentation

◆ from_json()

ServerState coordinator.server_state.ServerState.from_json ( str  state_json)
static

Definition at line 32 of file server_state.py.

32  def from_json(state_json: str) -> ServerState:
33  return ServerState._from_json_dict(
34  json.loads(state_json))
35 

◆ have_all_contributions()

bool coordinator.server_state.ServerState.have_all_contributions (   self)
returns True if all contributions have been received

Definition at line 36 of file server_state.py.

36  def have_all_contributions(self) -> bool:
37  """
38  returns True if all contributions have been received
39  """
40  return self.num_contributors <= self.next_contributor_index
41 
Here is the caller graph for this function:

◆ received_contribution()

None coordinator.server_state.ServerState.received_contribution (   self,
float  next_deadline 
)
Update the state after new contribution has been successfully received.

Definition at line 42 of file server_state.py.

42  def received_contribution(self, next_deadline: float) -> None:
43  """
44  Update the state after new contribution has been successfully received.
45  """
46  assert not self.have_all_contributions()
47  self._next_contributor(next_deadline)
48 
Here is the call graph for this function:

◆ to_json()

str coordinator.server_state.ServerState.to_json (   self)

Definition at line 28 of file server_state.py.

28  def to_json(self) -> str:
29  return json.dumps(self._to_json_dict())
30 
Here is the call graph for this function:

◆ update()

bool coordinator.server_state.ServerState.update (   self,
float  now,
float  interval 
)
Check whether a contributor has missed his chance and update internal
state accordingly. If the deadline has passed, return True. Otherwise
return False.

Definition at line 49 of file server_state.py.

49  def update(self, now: float, interval: float) -> bool:
50  """
51  Check whether a contributor has missed his chance and update internal
52  state accordingly. If the deadline has passed, return True. Otherwise
53  return False.
54  """
55  # If the next contributor deadline has passed, update
56  if self.next_contributor_deadline <= 0.0 or \
57  now < self.next_contributor_deadline:
58  return False
59 
60  self._next_contributor(now + interval)
61  return True
62 
Here is the call graph for this function:

Member Data Documentation

◆ next_contributor_deadline

coordinator.server_state.ServerState.next_contributor_deadline

Definition at line 66 of file server_state.py.

◆ next_contributor_index

coordinator.server_state.ServerState.next_contributor_index

Definition at line 64 of file server_state.py.


The documentation for this class was generated from the following file: