Ejemplo n.º 1
0
def get_unvoted_blocks(connection, node_pubkey):
    unvoted = connection.run(
        r.table('bigchain', read_mode=READ_MODE).filter(
            lambda block: r.table('votes', read_mode=READ_MODE).get_all(
                [block['id'], node_pubkey], index='block_and_voter').is_empty(
                )).order_by(r.asc(r.row['block']['timestamp'])))

    # FIXME: I (@vrde) don't like this solution. Filtering should be done at a
    #        database level. Solving issue #444 can help untangling the situation
    unvoted_blocks = filter(lambda block: not util.is_genesis_block(block),
                            unvoted)
    return unvoted_blocks
Ejemplo n.º 2
0
    def get_unvoted_blocks(self):
        """Return all the blocks that has not been voted by this node."""

        unvoted = r.table('bigchain', read_mode=self.read_mode) \
            .filter(lambda block: r.table('votes', read_mode=self.read_mode)
                    .get_all([block['id'], self.me], index='block_and_voter')
                    .is_empty()) \
            .order_by(r.asc(r.row['block']['timestamp'])) \
            .run(self.conn)

        # FIXME: I (@vrde) don't like this solution. Filtering should be done at a
        #        database level. Solving issue #444 can help untangling the situation
        unvoted = filter(lambda block: not util.is_genesis_block(block), unvoted)

        return list(unvoted)
Ejemplo n.º 3
0
    def get_unvoted_blocks(self):
        """Return all the blocks that has not been voted by this node."""

        unvoted = (
            r.table("bigchain")
            .filter(lambda block: r.table("votes").get_all([block["id"], self.me], index="block_and_voter").is_empty())
            .order_by(r.asc(r.row["block"]["timestamp"]))
            .run(self.conn)
        )

        # FIXME: I (@vrde) don't like this solution. Filtering should be done at a
        #        database level. Solving issue #444 can help untangling the situation
        unvoted = filter(lambda block: not util.is_genesis_block(block), unvoted)

        return list(unvoted)
Ejemplo n.º 4
0
    def get_unvoted_blocks(self, node_pubkey):
        """Return all the blocks that have not been voted by the specified node.

        Args:
            node_pubkey (str): base58 encoded public key

        Returns:
            :obj:`list` of :obj:`dict`: a list of unvoted blocks
        """

        unvoted = self.connection.run(
                r.table('bigchain', read_mode=self.read_mode)
                .filter(lambda block: r.table('votes', read_mode=self.read_mode)
                                       .get_all([block['id'], node_pubkey], index='block_and_voter')
                                       .is_empty())
                .order_by(r.asc(r.row['block']['timestamp'])))

        # FIXME: I (@vrde) don't like this solution. Filtering should be done at a
        #        database level. Solving issue #444 can help untangling the situation
        unvoted_blocks = filter(lambda block: not util.is_genesis_block(block), unvoted)
        return unvoted_blocks
Ejemplo n.º 5
0
    def get_unvoted_blocks(self, node_pubkey):
        """Return all the blocks that have not been voted by the specified node.

        Args:
            node_pubkey (str): base58 encoded public key

        Returns:
            :obj:`list` of :obj:`dict`: a list of unvoted blocks
        """

        unvoted = self.connection.run(
            r.table('bigchain', read_mode=self.read_mode).filter(
                lambda block: r.table('votes', read_mode=self.read_mode).
                get_all([block['id'], node_pubkey], index='block_and_voter').
                is_empty()).order_by(r.asc(r.row['block']['timestamp'])))

        # FIXME: I (@vrde) don't like this solution. Filtering should be done at a
        #        database level. Solving issue #444 can help untangling the situation
        unvoted_blocks = filter(lambda block: not util.is_genesis_block(block),
                                unvoted)
        return unvoted_blocks