Zeth - Zerocash on Ethereum  0.8
Reference implementation of the Zeth protocol by Clearmatics
null_contribution_handler.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
2 
3 # Copyright (c) 2015-2022 Clearmatics Technologies Ltd
4 #
5 # SPDX-License-Identifier: LGPL-3.0+
6 
7 from coordinator.icontributionhandler import IContributionHandler
8 
9 import os
10 import os.path
11 
12 CONTRIBUTION_FILE_NAME = "contrib"
13 FINAL_FILE_NAME = "final-upload"
14 
15 
17  """
18  A null handler that accepts contributions and simply stores them as
19  subsequent challenges. When the MPC has completed, the latest contribution
20  is moved to 'final-upload'. Can be used for testing coordinator
21  configuration (certificate setup, etc).
22  """
23 
24  def get_current_challenge_file(self, _next_contributor_idx: int) -> str:
25  return CONTRIBUTION_FILE_NAME
26 
28  self, _contributionn_idx: int, file_name: str) -> bool:
29  os.rename(file_name, CONTRIBUTION_FILE_NAME)
30  return True
31 
32  def on_completed(self) -> None:
33  assert not os.path.exists(FINAL_FILE_NAME)
34  if os.path.exists(CONTRIBUTION_FILE_NAME):
35  os.rename(CONTRIBUTION_FILE_NAME, FINAL_FILE_NAME)
36  else:
37  print("WARNING: no contributions found")
coordinator.icontributionhandler.IContributionHandler
Definition: icontributionhandler.py:16
coordinator.null_contribution_handler.NullContributionHandler.process_contribution
bool process_contribution(self, int _contributionn_idx, str file_name)
Definition: null_contribution_handler.py:27
coordinator.icontributionhandler
Definition: icontributionhandler.py:1
coordinator.null_contribution_handler.NullContributionHandler.get_current_challenge_file
str get_current_challenge_file(self, int _next_contributor_idx)
Definition: null_contribution_handler.py:24
coordinator.null_contribution_handler.NullContributionHandler
Definition: null_contribution_handler.py:16
coordinator.null_contribution_handler.NullContributionHandler.on_completed
None on_completed(self)
Definition: null_contribution_handler.py:32