code: def blocks(delegate_pubkey=None, max_timestamp=None):
          
  
          if not delegate_pubkey:
              delegate_pubkey = c.DELEGATE['PUBKEY']
          if max_timestamp:
              max_timestamp_sql = """ blocks."timestamp" <= {} AND""".format(max_timestamp)
          else:
              max_timestamp_sql = ''
  
          qry = DbCursor().execute_and_fetchall("""
               SELECT blocks."timestamp", blocks."height", blocks."id", blocks."totalFee", blocks."reward"
               FROM blocks
               WHERE {0} blocks."generatorPublicKey" = '\\x{1}'
               ORDER BY blocks."timestamp" 
               ASC""".format(
              max_timestamp_sql,
              delegate_pubkey))
  
          Block = namedtuple('block',
                             'timestamp height id totalFee reward')
          block_list = []
          for block in qry:
              block_value = Block(timestamp=block[0],
                                  height=block[1],
                                  id=block[2],
                                  totalFee=block[3],
                                  reward=block[4])
              block_list.append(block_value)
  
          return block_list
docs: returns a list of named tuples of all blocks forged by a delegate.
          if delegate_pubkey is not specified, set_delegate needs to be called in advance.
          max_timestamp can be configured to retrieve blocks up to a certain timestamp.