示例#1
0
    def __call__(self, length=1, head=None, min_date=None):
        if isinstance(head, str) and not is_bh(head):
            head = self.__getitem__(head).calculate_hash()

        if min_date and not isinstance(min_date, int):
            min_date = to_timestamp(min_date)

        return super(BlockListList, self).__call__(length=length,
                                                   head=head,
                                                   min_date=min_date)
示例#2
0
    def __call__(self) -> list:
        """ Get block hashes (base58) for this interval.
        """
        if is_bh(self._stop):
            head = self._stop
        else:
            head = self._getitem(self._stop).hash()

        if self._start < 0:
            length = abs(self._start)
        else:
            header = self._getitem(self._stop).header()
            length = header['level'] - self._start + 1

        return super(BlockSliceQuery, self).__call__(length=length, head=head)
示例#3
0
    def __call__(self, length=1, head=None, min_date=None):
        """ Lists known heads of the blockchain sorted with decreasing fitness.
        Optional arguments allows to returns the list of predecessors for known heads
        or the list of predecessors for a given list of blocks.

        :param length: The requested number of predecessors to returns (per requested head).
        :param head: An empty argument requests blocks from the current heads. \
        A non empty list allow to request specific fragment of the chain.
        :param min_date: When `min_date` is provided, heads with a timestamp before `min_date` are filtered out
        :rtype: list[list[str]]
        """
        if isinstance(head, str) and not is_bh(head):
            head = self.__getitem__(head).calculate_hash()

        if min_date and not isinstance(min_date, int):
            min_date = to_timestamp(min_date)

        return super(BlocksQuery, self).__call__(
            length=length, head=head, min_date=min_date)
示例#4
0
 def test_is_bh(self, value, expected):
     self.assertEqual(expected, is_bh(value))