refactor state hash output+filter

This commit is contained in:
Dmitry Belyaev 2024-02-20 11:11:00 +03:00
parent b7097540a2
commit 3d2f046dcf
Signed by: b4tman
GPG Key ID: 41A00BF15EA7E5F3
2 changed files with 2 additions and 10 deletions

View File

@ -12,11 +12,7 @@ class StateHashFilter(BaseFilterProvider):
if not isfile(self.config["filepath"]):
return True
new_state = {
"ipv4": addr_v4 or "",
"ipv6": addr_v6 or "",
}
new_state_str = json.dumps(new_state)
new_state_str = (addr_v4 or "") + (addr_v6 or "")
new_sha = hashlib.sha256(new_state_str.encode(encoding="utf-8"))
async with aiofiles.open(
self.config["filepath"], mode="r", encoding="utf-8"

View File

@ -21,11 +21,7 @@ class StateFile(BaseOutputProvider):
class StateHashFile(BaseOutputProvider):
async def set_addrs_imp(self, source_provider, addr_v4, addr_v6):
state = {
"ipv4": addr_v4 or "",
"ipv6": addr_v6 or "",
}
state_str = json.dumps(state)
state_str = (addr_v4 or "") + (addr_v6 or "")
sha = hashlib.sha256(state_str.encode(encoding="utf-8"))
async with aiofiles.open(
self.config["filepath"], mode="w", encoding="utf-8"