import time

class Getwork_store:
    
    def __init__(self):
        self.data = {}
    
    def add(self, server, merkle_root):
        self.data[merkle_root] = {'name':server["name"], 'timestamp':time.time()}
        return
    
    def get_server(self, merkle_root):
        if self.data.has_key(merkle_root):
            return self.data[merkle_root]['name']
        return None
    
    def prune(self):
        for key, work in self.data.items():
            if work['timestamp'] < (time.time() - (60*5)):
                del self.data[key]
        return


import time

from twisted.internet.task import LoopingCall

class Getwork_store:
    
    def __init__(self):
        self.data = {}
        call = LoopingCall(self.prune)
        call.start(60)

    def add(self, server, merkle_root):
        self.data[merkle_root] = [server["name"], time.time()]
    
    def get_server(self, merkle_root):
        if self.data.has_key(merkle_root):
            return self.data[merkle_root][0]
        return None
    
    def prune(self):
        for key, work in self.data.items():
            if work[1] < (time.time() - (60*5)):
                del self.data[key]

Update getwork to prune itself and use a list instead of a dictionary
Update getwork to prune itself and use a list instead of a dictionary

+ 
  import time
+ 
+ from twisted.internet.task import LoopingCall
  
  class Getwork_store:
      
      def __init__(self):
          self.data = {}
-     
+         call = LoopingCall(self.prune)
+         call.start(60)
+ 
      def add(self, server, merkle_root):
-         self.data[merkle_root] = {'name':server["name"], 'timestamp':time.time()}
+         self.data[merkle_root] = [server["name"], time.time()]
-         return
      
      def get_server(self, merkle_root):
          if self.data.has_key(merkle_root):
-             return self.data[merkle_root]['name']
+             return self.data[merkle_root][0]
          return None
      
      def prune(self):
          for key, work in self.data.items():
-             if work['timestamp'] < (time.time() - (60*5)):
+             if work[1] < (time.time() - (60*5)):
                  del self.data[key]
-         return
  
Update getwork to prune itself and use a list instead of a dictionary
## Code Before:
import time

class Getwork_store:
    
    def __init__(self):
        self.data = {}
    
    def add(self, server, merkle_root):
        self.data[merkle_root] = {'name':server["name"], 'timestamp':time.time()}
        return
    
    def get_server(self, merkle_root):
        if self.data.has_key(merkle_root):
            return self.data[merkle_root]['name']
        return None
    
    def prune(self):
        for key, work in self.data.items():
            if work['timestamp'] < (time.time() - (60*5)):
                del self.data[key]
        return

## Instruction:
Update getwork to prune itself and use a list instead of a dictionary
## Code After:

import time

from twisted.internet.task import LoopingCall

class Getwork_store:
    
    def __init__(self):
        self.data = {}
        call = LoopingCall(self.prune)
        call.start(60)

    def add(self, server, merkle_root):
        self.data[merkle_root] = [server["name"], time.time()]
    
    def get_server(self, merkle_root):
        if self.data.has_key(merkle_root):
            return self.data[merkle_root][0]
        return None
    
    def prune(self):
        for key, work in self.data.items():
            if work[1] < (time.time() - (60*5)):
                del self.data[key]
