Add resume of filter in syncitem
This commit is contained in:
parent
ca1441d50d
commit
b192dd6e95
@ -43,6 +43,7 @@ class FilterState:
|
||||
self.state_store.add('RESET')
|
||||
|
||||
self.state = self.state_store.state
|
||||
self.elements = self.state_store.elements
|
||||
self.put = self.state_store.put
|
||||
self.mask = self.state_store.mask
|
||||
self.name = self.state_store.name
|
||||
|
@ -135,9 +135,6 @@ def main():
|
||||
else:
|
||||
locked_item.advance(ignore_lock=True)
|
||||
store.filter_state.unset(locked_item_key, lock_state)
|
||||
#next_filter = filter_list[filter_pos]
|
||||
#next_state = store.filter_state.from_name(next_filter)
|
||||
#store.filter_state.move(next_state)
|
||||
else:
|
||||
filter_mask = 0xf
|
||||
filter_state = store.filter_state.mask(locked_state, filter_mask)
|
||||
|
@ -47,7 +47,8 @@ class SyncItem:
|
||||
|
||||
(self.cursor, self.tx_cursor, self.target) = sync_state_deserialize(v)
|
||||
|
||||
if self.filter_state.state(self.state_key) & self.filter_state.from_name('LOCK') > 0 and not ignore_lock:
|
||||
filter_state = self.filter_state.state(self.state_key)
|
||||
if filter_state & self.filter_state.from_name('LOCK') > 0 and not ignore_lock:
|
||||
raise LockError(self.state_key)
|
||||
|
||||
self.count = len(self.filter_state.all(pure=True)) - 4
|
||||
@ -65,6 +66,16 @@ class SyncItem:
|
||||
raise FilterDone(self.state_key)
|
||||
|
||||
|
||||
def resume(self):
|
||||
filter_state = self.filter_state.state(self.state_key)
|
||||
if filter_state > 0x0f:
|
||||
filter_state_part = self.filter_state.mask(filter_state, 0x0f)
|
||||
if len(self.filter_state.elements(filter_state)) == 1:
|
||||
logg.info('resume execution on state {} ({})'.format(self.filter_state.name(filter_state_part), filter_state_part))
|
||||
lock_state = self.filter_state.from_name('LOCK')
|
||||
self.filter_state.set(lock_state)
|
||||
|
||||
|
||||
def reset(self, check_incomplete=True):
|
||||
if check_incomplete:
|
||||
if self.filter_state.state(self.state_key) & self.filter_state.from_name('LOCK') > 0:
|
||||
@ -210,6 +221,7 @@ class SyncStore:
|
||||
self.state.put(block_number_str, contents=state_bytes)
|
||||
self.filter_state.put(block_number_str)
|
||||
o = SyncItem(offset, target, self.state, self.filter_state, ignore_lock=ignore_lock)
|
||||
o.resume()
|
||||
self.items[offset] = o
|
||||
self.item_keys.append(offset)
|
||||
elif offset > 0:
|
||||
@ -259,6 +271,7 @@ class SyncStore:
|
||||
if i < lim:
|
||||
item_target = thresholds[i+1]
|
||||
o = SyncItem(block_number, item_target, self.state, self.filter_state, started=True, ignore_lock=ignore_lock)
|
||||
o.resume()
|
||||
self.items[block_number] = o
|
||||
self.item_keys.append(block_number)
|
||||
logg.info('added existing {}'.format(o))
|
||||
|
@ -1,5 +1,5 @@
|
||||
confini~=0.6.0
|
||||
semver==2.13.0
|
||||
hexathon~=0.1.5
|
||||
chainlib>=0.1.0b1,<0.2.0
|
||||
chainlib~=0.1.1
|
||||
shep~=0.2.3
|
||||
|
Loading…
Reference in New Issue
Block a user