예제 #1
0
    def apply_license_1(self):
        """
        Let head alliance own the license 1.
        """
        color = 1

        alliance = Alliance(env.host, self.collect_addresses[env.host]['default'])
        self.applied_colors[color] = alliance.address

        return alliance.apply_license_1(alliance.address, config.MAX_COIN)
예제 #2
0
    def apply_license_1(self):
        """
        Let head alliance own the license 1.
        """
        color = 1

        alliance = Alliance(env.host, self.collect_addresses[env.host]['default'])
        self.applied_colors[color] = alliance.address

        return alliance.apply_license_1(alliance.address, config.MAX_COIN)
예제 #3
0
    def setup_head_alliance(self):
        alliance = Alliance(env.host, self.collect_addresses[env.host]['default'])

        if env.host == env.roledefs['alliance'][0]:
            alliance.start_mining()
        else:
            # To ensure that other alliance acknowledge the first alliance
            acknowledged = False
            while not acknowledged:
                if alliance.getblockcount() > 0:
                    acknowledged = True
예제 #4
0
    def random_apply_license(self):
        result = {}

        alliance = Alliance(env.host, self.collect_addresses[env.host]['default'])
        address = self._random_choose_an_address('issuer')
        color = self._random_choose_an_unused_color()

        alliance.apply_license_normal(address, color, self.applied_colors[1])
        result = {color: address}

        return result
예제 #5
0
    def setup_head_alliance(self):
        alliance = Alliance(env.host, self.collect_addresses[env.host]['default'])

        if env.host == env.roledefs['alliance'][0]:
            alliance.start_mining()
        else:
            # To ensure that other alliance acknowledge the first alliance
            acknowledged = False
            while not acknowledged:
                if alliance.getblockcount() > 0:
                    acknowledged = True
예제 #6
0
    def random_apply_license(self):
        result = {}

        alliance = Alliance(env.host, self.collect_addresses[env.host]['default'])
        address = self._random_choose_an_address('issuer')
        color = self._random_choose_an_unused_color()

        alliance.apply_license_normal(address, color, self.applied_colors[1])
        result = {color: address}

        return result
예제 #7
0
    def vote_and_send_color1_coins(self):
        alliance = Alliance(env.host, self.collect_addresses[env.host]['default'])

        if env.host == env.roledefs['alliance'][0]:
            num_alliance = len(env.roledefs['alliance'][1:])
            alliance.mint_0(num_alliance)
            for host in env.roledefs['alliance'][1:]:
                alliance.vote(self.collect_addresses[host]['default'])

                '''
                # send lot of color 1 coin to other alliance (for the use of activate member)
                amount_1 = config.NUM_ISSUER_PER_ALLIANCE * config.NUM_MEMBERS_PER_ISSUER
                alliance.send_coins(alliance.address,
                                    self.collect_addresses[host]['default'],
                                    amount_1, 1)
                '''
        else:
            while not alliance.is_alliance():
                time.sleep(1)
            my_pos = env.roledefs['alliance'].index(env.host)
            for host in env.roledefs['alliance'][my_pos+1:]:
                alliance.vote(self.collect_addresses[host]['default'])
예제 #8
0
    def start_all_miners(self):
        alliance = Alliance(env.host, self.collect_addresses[env.host]['default'])

        return alliance.start_mining()
예제 #9
0
    def start_all_miners(self):
        alliance = Alliance(env.host, self.collect_addresses[env.host]['default'])

        return alliance.start_mining()
예제 #10
0
    def vote_and_send_color1_coins(self):
        alliance = Alliance(env.host, self.collect_addresses[env.host]['default'])
        num_alliance = len(env.roledefs['alliance'][0:])

        if env.host == env.roledefs['alliance'][0]:
            alliance.mint_0(num_alliance - 1)
            membernum = alliance.membernum()
            for host in env.roledefs['alliance'][1:]:
                alliance.vote(self.collect_addresses[host]['default'])
                while membernum == alliance.membernum() and membernum != 8:
                    time.sleep(3)
                membernum = alliance.membernum()

                '''
                # send lot of color 1 coin to other alliance (for the use of activate member)
                amount_1 = config.NUM_ISSUER_PER_ALLIANCE * config.NUM_MEMBERS_PER_ISSUER
                alliance.send_coins(alliance.address,
                                    self.collect_addresses[host]['default'],
                                    amount_1, 1)
                '''
        else:
            while not alliance.is_alliance():
                time.sleep(3)

            num_mint = num_alliance - alliance.membernum()
            if num_mint > 0:
                alliance.mint_0(num_mint)
                my_pos = env.roledefs['alliance'].index(env.host)
                membernum = alliance.membernum()
                for host in env.roledefs['alliance'][my_pos:]:
                    if not host == env.host:
                        alliance.vote(self.collect_addresses[host]['default'])
                        while membernum == alliance.membernum() and membernum != 8:
                            time.sleep(3)
                        membernum = alliance.membernum()