コード例 #1
0
    def get_locator(self):
        """
        Get a block locator object to give our remote peer when fetching headers/merkle blocks.
        """

        locator = CBlockLocator()
        parent = self.get_block_id(self.get_height())

        def rollback(parent, n):
            for i in range(n):
                parent = self._get_parent(parent)
            return parent

        step = -1
        start = 0
        height = self.get_height()
        while (True):
            if start >= 10:
                step *= 2
                start = 0
            locator.vHave.append(lx(parent))
            parent = rollback(parent, abs(step))
            start += 1
            height += step
            if height <= self._get_starting_height() + abs(step):
                break
        return locator
コード例 #2
0
 def send_getheaders(self, block_hash_string):
     locator = CBlockLocator()
     locator.vHave = [lx(block_hash_string)]
     msg = msg_getheaders()
     msg.locator = locator
     self.send_message(msg)
コード例 #3
0
ファイル: messages.py プロジェクト: ghtdak/python-bitcoinlib
 def __init__(self, protover=PROTO_VERSION):
     super(msg_getheaders, self).__init__(protover)
     self.locator = CBlockLocator()
     self.hashstop = b'\x00'*32