[KMS-ETH]- Publish arrangement method

pull/195/head^2
Kieran Prasch 2018-04-06 17:14:34 -07:00
parent c75392598c
commit 9f4c960963
2 changed files with 29 additions and 0 deletions

View File

@ -63,3 +63,31 @@ class BlockchainPolicy:
def __init__(self):
self._arrangements = list()
def publish_arrangement(self, miner, periods: int, rate: int, arrangement_id: bytes=None) -> 'BlockchainArrangement':
"""
Create a new arrangement to carry out a blockchain policy for the specified rate and time.
"""
value = rate * periods
arrangement = BlockchainArrangement(author=self,
miner=miner,
value=value,
periods=periods)
self._arrangements[arrangement.id] = {arrangement_id: arrangement}
return arrangement
def get_arrangement(self, arrangement_id: bytes) -> BlockchainArrangement:
"""Fetch a published arrangement from the blockchain"""
blockchain_record = self.policy_agent.read().policies(arrangement_id)
author_address, miner_address, rate, start_block, end_block, downtime_index = blockchain_record
duration = end_block - start_block
miner = Miner(address=miner_address, miner_agent=self.policy_agent.miner_agent)
arrangement = BlockchainArrangement(author=self, miner=miner, periods=duration)
arrangement.is_published = True
return arrangement

View File

@ -9,6 +9,7 @@ from nkms_eth.deployers import MinerEscrowDeployer, NuCypherKMSTokenDeployer
class TesterBlockchain(TheBlockchain):
"""Transient, in-memory, local, private chain"""
_network = 'tester'
def wait_time(self, wait_hours, step=50):