def initialize(): """initialize coins and locks""" log_msg('Initializing cache.', 3) previous, current = BankUtil.get_intervals() Globals.Acoins = {previous: [], current: []} for i in range(Globals.numberOfSets+1): Globals.Acoins[previous].append(set()) Globals.Acoins[current].append(set())
def initialize(): """initialize coins and locks""" log_msg('Initializing cache.', 3) previous, current = BankUtil.get_intervals() Globals.Acoins = {previous: [], current: []} for i in range(Globals.numberOfSets + 1): Globals.Acoins[previous].append(set()) Globals.Acoins[current].append(set())
def on_new_interval(): """removes expired acoins and locks from the cache and makes new ones""" previous, current = BankUtil.get_intervals() log_msg('New interval learned: %s!'%current, 3) if Globals.isInitialize: Globals.Acoins[current] = [] for repo in range(Globals.numberOfSets+1): #create new ones Globals.Acoins[current].append(set()) del(Globals.Acoins[previous-1]) else: initialize() Globals.isInitialize = True
def on_new_interval(): """removes expired acoins and locks from the cache and makes new ones""" previous, current = BankUtil.get_intervals() log_msg('New interval learned: %s!' % current, 3) if Globals.isInitialize: Globals.Acoins[current] = [] for repo in range(Globals.numberOfSets + 1): #create new ones Globals.Acoins[current].append(set()) del (Globals.Acoins[previous - 1]) else: initialize() Globals.isInitialize = True