kvstore/store.ipynb
2025-10-08 09:04:27 -04:00

129 lines
3.0 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import plyvel\n",
"\n",
"%run -i read_tree.py"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# db = plyvel.DB('../testnode/nodedir/data/application.db')\n",
"max_height(db)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"[k for k, v in iterate(db, 's/k:mint/', 5224815)]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"parse_struct(next(iterate(db, 's/k:mint/', 5224815, field = 138))[1])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"[k for k,v in iterate(db, 's/k:emissions/', 5224815, start = [62, 60], end = [62, 61], format = 'Qss')]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"lens = np.zeros(256, dtype = int)\n",
"\n",
"with plyvel.DB('../testnode/nodedir/data/application.db') as db:\n",
" height = max_height(db)\n",
" for field in range(255):\n",
" count1 = indexof(db, 's/k:emissions/', height, '', [field])\n",
" count2 = indexof(db, 's/k:emissions/', height, '', [field+1])\n",
" lens[field] = count2 - count1\n",
"\n",
"np.argsort(lens)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# def has_prefix(db, prefix: bytes) -> bool:\n",
"# it = db.iterator(start = prefix)\n",
"# try:\n",
"# first_key, _ = next(it)\n",
"# return first_key.startswith(prefix)\n",
"# except StopIteration:\n",
"# return False\n",
"# finally:\n",
"# it.close()\n",
"\n",
"# found = []\n",
"# prefixes = [b's/']\n",
"\n",
"# for i in range(20):\n",
"# new_prefixes = []\n",
"\n",
"# for p in prefixes:\n",
"# for i in range(256):\n",
"# b = p + bytes([i])\n",
"# if has_prefix(db, b):\n",
"# if b.endswith(b'/'):\n",
"# found.append((b, db.approximate_size(b, b + b'\\xff')))\n",
"# else:\n",
"# new_prefixes.append(b)\n",
"# # new_prefixes.append(b)\n",
"\n",
"# prefixes = new_prefixes\n",
"\n",
"# found"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
}