mirror of https://github.com/nucypher/nucypher.git
[KMS-ETH]- Publish arrangement method
parent
c75392598c
commit
9f4c960963
|
@ -63,3 +63,31 @@ class BlockchainPolicy:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._arrangements = list()
|
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
|
||||||
|
|
|
@ -9,6 +9,7 @@ from nkms_eth.deployers import MinerEscrowDeployer, NuCypherKMSTokenDeployer
|
||||||
|
|
||||||
class TesterBlockchain(TheBlockchain):
|
class TesterBlockchain(TheBlockchain):
|
||||||
"""Transient, in-memory, local, private chain"""
|
"""Transient, in-memory, local, private chain"""
|
||||||
|
|
||||||
_network = 'tester'
|
_network = 'tester'
|
||||||
|
|
||||||
def wait_time(self, wait_hours, step=50):
|
def wait_time(self, wait_hours, step=50):
|
||||||
|
|
Loading…
Reference in New Issue