refactor state hash output+filter
This commit is contained in:
parent
b7097540a2
commit
3d2f046dcf
@ -12,11 +12,7 @@ class StateHashFilter(BaseFilterProvider):
|
|||||||
if not isfile(self.config["filepath"]):
|
if not isfile(self.config["filepath"]):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
new_state = {
|
new_state_str = (addr_v4 or "") + (addr_v6 or "")
|
||||||
"ipv4": addr_v4 or "",
|
|
||||||
"ipv6": addr_v6 or "",
|
|
||||||
}
|
|
||||||
new_state_str = json.dumps(new_state)
|
|
||||||
new_sha = hashlib.sha256(new_state_str.encode(encoding="utf-8"))
|
new_sha = hashlib.sha256(new_state_str.encode(encoding="utf-8"))
|
||||||
async with aiofiles.open(
|
async with aiofiles.open(
|
||||||
self.config["filepath"], mode="r", encoding="utf-8"
|
self.config["filepath"], mode="r", encoding="utf-8"
|
||||||
|
@ -21,11 +21,7 @@ class StateFile(BaseOutputProvider):
|
|||||||
|
|
||||||
class StateHashFile(BaseOutputProvider):
|
class StateHashFile(BaseOutputProvider):
|
||||||
async def set_addrs_imp(self, source_provider, addr_v4, addr_v6):
|
async def set_addrs_imp(self, source_provider, addr_v4, addr_v6):
|
||||||
state = {
|
state_str = (addr_v4 or "") + (addr_v6 or "")
|
||||||
"ipv4": addr_v4 or "",
|
|
||||||
"ipv6": addr_v6 or "",
|
|
||||||
}
|
|
||||||
state_str = json.dumps(state)
|
|
||||||
sha = hashlib.sha256(state_str.encode(encoding="utf-8"))
|
sha = hashlib.sha256(state_str.encode(encoding="utf-8"))
|
||||||
async with aiofiles.open(
|
async with aiofiles.open(
|
||||||
self.config["filepath"], mode="w", encoding="utf-8"
|
self.config["filepath"], mode="w", encoding="utf-8"
|
||||||
|
Loading…
Reference in New Issue
Block a user