Processor.__init__(self)
self.shared = shared
+ self.config = config
self.up_to_date = False
self.watched_addresses = []
self.history_cache = {}
if sync or len(self.headers_data) > 40*100:
self.flush_headers()
+ with self.cache_lock:
+ chunk_index = header.get('block_height')/2016
+ if self.chunk_cache.get(chunk_index):
+ self.chunk_cache.pop(chunk_index)
+
def pop_header(self):
# we need to do this only if we have not flushed
if self.headers_data:
def get_chunk(self, i):
# store them on disk; store the current chunk in memory
- chunk = self.chunk_cache.get(i)
- if not chunk:
- chunk = self.read_chunk(i)
- self.chunk_cache[i] = chunk
+ with self.cache_lock:
+ chunk = self.chunk_cache.get(i)
+ if not chunk:
+ chunk = self.read_chunk(i)
+ self.chunk_cache[i] = chunk
+
return chunk
# re-add them to the history
self.add_to_history( prevout_addr, x.get('prevout_hash'), x.get('prevout_n'), prevout_height)
- print_log( "new hist for", hash_160_to_bc_address(prevout_addr), self.deserialize(self.batch_list[prevout_addr]) )
+ # print_log( "new hist for", hash_160_to_bc_address(prevout_addr), self.deserialize(self.batch_list[prevout_addr]) )
# write
max_len = 0
elif method == 'blockchain.address.unsubscribe':
try:
- address = params[0]
- self.watched_addresses.remove(address)
- print_log('unsubscribed', address)
- result = "ok"
+ password = params[0]
+ address = params[1]
+ if password == self.config.get('server','password'):
+ self.watched_addresses.remove(address)
+ print_log('unsubscribed', address)
+ result = "ok"
+ else:
+ print_log('incorrect password')
+ result = "authentication error"
except BaseException, e:
error = str(e) + ': ' + address
print_log( "error:", error )