def message(self, block: Union[str, int] = 'genesis') -> bytes: """Get payload for the failing noop operation :param block: Specify operation branch (default is genesis) :returns: Message bytes """ if len(self.contents) != 1 or self.contents[0]['kind'] != 'failing_noop': raise NotImplementedError('Use for signing messages only') branch = block if is_bh(str(block)) else self.shell.blocks[block].hash() return b'\x03' + bytes.fromhex(self._spawn(branch=branch).forge())
def __call__(self) -> list: # type: ignore """ Get block hashes (base58) for this interval. """ header = self._getitem(self._stop).header() if is_bh(self._stop): head = self._stop else: head = header['hash'] if self._start < 0: length = abs(self._start) else: length = header['level'] - self._start + 1 return super(BlockSliceQuery, self).__call__(length=min(header['level'], length), head=head)
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)
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)
def test_is_bh(self, value, expected): self.assertEqual(expected, is_bh(value))