# Path: hydrachain/consensus/base.py
# class Proposal(Signed):
#     pass
# 
# def isaddress(a):
#     return isinstance(a, bytes) and len(a) == 20


from .base import Proposal, isaddress


class ConsensusContract(object):

    def __init__(self, validators):
        for v in validators:
            assert isaddress(v)
        self.validators = validators

    def proposer(self, height, round_):
        v = abs(hash(repr((height, round_))))
        return self.validators[v % len(self.validators)]

    def isvalidator(self, address, height=0):

# Path: hydrachain/consensus/base.py
# class Proposal(Signed):
#     pass
# 
# def isaddress(a):
#     return isinstance(a, bytes) and len(a) == 20


# Path: hydrachain/consensus/contract.py
from .base import Proposal, isaddress



class ConsensusContract(object):

    def __init__(self, validators):
        for v in validators:
            assert isaddress(v)
        self.validators = validators

    def proposer(self, height, round_):
        v = abs(hash(repr((height, round_))))
        return self.validators[v % len(self.validators)]

    def isvalidator(self, address, height=0):

        assert isaddress(address)