code: def verify_header_chain(cls, path, chain=None):
          
          if chain is None:
              chain = SPVClient.load_header_chain( path )
  
          prev_header = chain[0]
          
          for i in xrange(1, len(chain)):
              header = chain[i]
              height = header.get('block_height')
              prev_hash = prev_header.get('hash')
              if prev_hash != header.get('prev_block_hash'):
                  log.error("prev hash mismatch: %s vs %s" % (prev_hash, header.get('prev_block_hash')))
                  return False
  
              bits, target = SPVClient.get_target( path, height/BLOCK_DIFFICULTY_CHUNK_SIZE, chain)
              if bits != header.get('bits'):
                  log.error("bits mismatch: %s vs %s" % (bits, header.get('bits')))
                  return False
  
              _hash = header.get('hash')
              if int('0x'+_hash, 16) > target:
                  log.error("insufficient proof of work: %s vs target %s" % (int('0x'+_hash, 16), target))
                  return False
  
              prev_header = header
  
          return True
docs: Verify that a given chain of block headers
          has sufficient proof of work.