code: def ensure_header(self, header: BlockHeader=None) -> BlockHeader:
          
          if header is None:
              head = self.get_canonical_head()
              return self.create_header_from_parent(head)
          else:
              return header
docs: Return ``header`` if it is not ``None``, otherwise return the header
          of the canonical head.