commit 9bd61f71bbd150271cde48bb2cb1f84eb9eb5b97
parent 4b8d031b6c824566bc2d0e4ca962729665d426b5
Author: nolash <dev@holbrook.no>
Date: Tue, 23 Feb 2021 08:24:57 +0100
Use hex for digest
Diffstat:
4 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/chainsyncer/db/models/filter.py b/chainsyncer/db/models/filter.py
@@ -3,14 +3,14 @@ import logging
import hashlib
# external imports
-from sqlalchemy import Column, String, Integer, BLOB, ForeignKey
+from sqlalchemy import Column, String, Integer, LargeBinary, ForeignKey
from sqlalchemy.ext.hybrid import hybrid_property, hybrid_method
# local imports
from .base import SessionBase
from .sync import BlockchainSync
-zero_digest = bytearray(32)
+zero_digest = bytes(32).hex()
logg = logging.getLogger(__name__)
@@ -19,9 +19,9 @@ class BlockchainSyncFilter(SessionBase):
__tablename__ = 'chain_sync_filter'
chain_sync_id = Column(Integer, ForeignKey('chain_sync.id'))
- flags_start = Column(BLOB)
- flags = Column(BLOB)
- digest = Column(BLOB)
+ flags_start = Column(LargeBinary)
+ flags = Column(LargeBinary)
+ digest = Column(String(64))
count = Column(Integer)
@@ -42,7 +42,7 @@ class BlockchainSyncFilter(SessionBase):
def add(self, name):
h = hashlib.new('sha256')
- h.update(self.digest)
+ h.update(bytes.fromhex(self.digest))
h.update(name.encode('utf-8'))
z = h.digest()
@@ -52,7 +52,7 @@ class BlockchainSyncFilter(SessionBase):
if old_byte_count != new_byte_count:
self.flags = bytearray(1) + self.flags
self.count += 1
- self.digest = z
+ self.digest = z.hex()
def start(self):
diff --git a/setup.cfg b/setup.cfg
@@ -1,6 +1,6 @@
[metadata]
name = chainsyncer
-version = 0.0.1a12
+version = 0.0.1a14
description = Generic blockchain syncer driver
author = Louis Holbrook
author_email = dev@holbrook.no
diff --git a/sql/postgresql/2.sql b/sql/postgresql/2.sql
@@ -5,7 +5,7 @@ CREATE TABLE IF NOT EXISTS chain_sync_filter (
flags bytea default null,
flags_start bytea default null,
count integer not null default 0,
- digest bytea not null,
+ digest char(64) not null,
CONSTRAINT fk_chain_sync
FOREIGN KEY(chain_sync_id)
REFERENCES chain_sync(id)
diff --git a/sql/sqlite/2.sql b/sql/sqlite/2.sql
@@ -4,7 +4,7 @@ CREATE TABLE IF NOT EXISTS chain_sync_filter (
flags bytea default null,
flags_start bytea default null,
count integer not null default 0,
- digest bytea not null,
+ digest char(64) not null,
CONSTRAINT fk_chain_sync
FOREIGN KEY(chain_sync_id)
REFERENCES chain_sync(id)