old_contents: # The ResourceTable class contains the data structure of the ResourceTable class, and methods includes add, remove, clear.
  
  import sys
  import struct
  import time, threading
  from Record import Record
  from RecordStatus import RecordStatus
  
  class ResourceTable:
      """docstring for ResourceTable"""
      def __init__(self):
          # initialization
          self.records = []
          self.run()
  
      def run(self):
          # excute once per second
          threading.Timer(1, self.run).start()
  
          for record in self.records:
              if record.ip_addr != '127.0.0.1':
                  record.ttl -= 1
                  if record.ttl == 0:
                      self.remove(record)
  
      def add(self, record):
          self.records.append(record)
  
      def remove(self, record):
          self.records.remove(record)
  
      def clear(self):
          self.records = []
  
      def updateStatus(self, fid, ip_addr, status):
          for record in self.records:
              if record.fid == fid and record.ip_addr == ip_addr:
                  record.status = status
  
  """Write the test code here"""
  if __name__ == '__main__':
      resourceTable = ResourceTable()
      resourceTable.add(Record(b'123456789012345678901234567890123456789012345678901234567890efgh', '111.10.10.11', 0))
      print (resourceTable.records[0].ttl)
      while resourceTable.records[0].ttl != 30:
          pass
      print (resourceTable.records[0].ttl)
      
      resourceTable.add(Record(b'123456789012345678901234567890123456789012345678901234567890abcd', '127.0.0.1', 0))
      while len(resourceTable.records) != 1:
          pass
      print (len(resourceTable.records))
      print ("ResourceTable class should work if you see this")
new_contents: # The ResourceTable class contains the data structure of the ResourceTable class, and methods includes add, remove, clear.
  
  import sys
  import struct
  import time, threading
  from Record import Record
  from RecordStatus import RecordStatus
  
  class ResourceTable:
      """docstring for ResourceTable"""
      def __init__(self):
          # initialization
          self.records = []
          self.run()
  
      def run(self):
          # excute once per second
          threading.Timer(1, self.run).start()
  
          for record in self.records:
              if record.ip_addr != '127.0.0.1':
                  record.ttl -= 1
                  if record.ttl == 0:
                      self.remove(record)
  
      def add(self, record):
          # if same record is already exist in the table, remove it.
          for r in self.records:
              if r.fid == record.fid and r.ip_addr == record.ip_addr and r.status == record.status:
                  self.records.remove(record)
          self.records.append(record)
  
      def remove(self, record):
          self.records.remove(record)
  
      def clear(self):
          self.records = []
  
      def updateStatus(self, fid, ip_addr, status):
          for record in self.records:
              if record.fid == fid and record.ip_addr == ip_addr:
                  record.status = status
  
  """Write the test code here"""
  if __name__ == '__main__':
      resourceTable = ResourceTable()
      resourceTable.add(Record(b'123456789012345678901234567890123456789012345678901234567890efgh', '111.10.10.11', 0))
      print (resourceTable.records[0].ttl)
      while resourceTable.records[0].ttl != 30:
          pass
      print (resourceTable.records[0].ttl)
      
      resourceTable.add(Record(b'123456789012345678901234567890123456789012345678901234567890abcd', '127.0.0.1', 0))
      while len(resourceTable.records) != 1:
          pass
      print (len(resourceTable.records))
      print ("ResourceTable class should work if you see this")
subject: Remove duplicated records in Resource Table.