Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Use uint32 for flush count packing #176

Merged
merged 2 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ jobs:
- name: Run tests
run: |
pip install pytest
pytest --cov=electrumx --ignore=tests/test_blocks.py
pytest --cov=electrumx --ignore=tests/test_blocks.py --ignore=tests/server/test_compaction.py
4 changes: 2 additions & 2 deletions electrumx/server/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import electrumx.lib.util as util
from electrumx.lib.hash import HASHX_LEN, hash_to_hex_str
from electrumx.lib.util import (pack_be_uint16, pack_le_uint64,
from electrumx.lib.util import (pack_be_uint16, pack_be_uint32, pack_le_uint64,
unpack_be_uint16_from, unpack_le_uint64)

if TYPE_CHECKING:
Expand Down Expand Up @@ -157,7 +157,7 @@ def assert_flushed(self):
def flush(self):
start_time = time.monotonic()
self.flush_count += 1
flush_id = pack_be_uint16(self.flush_count)
flush_id = pack_be_uint32(self.flush_count)
unflushed = self.unflushed

with self.db.write_batch() as batch:
Expand Down
6 changes: 3 additions & 3 deletions tests/server/test_compaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pytest

from electrumx.lib.hash import HASHX_LEN
from electrumx.lib.util import pack_be_uint16, pack_le_uint64
from electrumx.lib.util import pack_be_uint16, pack_be_uint32, pack_le_uint64
from electrumx.server.env import Env
from electrumx.server.db import DB

Expand Down Expand Up @@ -49,7 +49,7 @@ def check_hashX_compaction(history):
hist_list = []
hist_map = {}
for flush_count, count in pairs:
key = hashX + pack_be_uint16(flush_count)
key = hashX + pack_be_uint32(flush_count)
hist = full_hist[cum * 5: (cum+count) * 5]
hist_map[key] = hist
hist_list.append(hist)
Expand All @@ -68,7 +68,7 @@ def check_hashX_compaction(history):
assert item == (hashX + pack_be_uint16(n),
full_hist[n * row_size: (n + 1) * row_size])
for flush_count, count in pairs:
assert hashX + pack_be_uint16(flush_count) in keys_to_delete
assert hashX + pack_be_uint32(flush_count) in keys_to_delete

# Check re-compaction is null
hist_map = {key: value for key, value in write_items}
Expand Down
Loading