Compare commits

..

No commits in common. "ebb1e24e273bca5a9633f60f351bf81752ddd81c" and "b16fb0cf3c78ba4e9616829ab2458528588a1677" have entirely different histories.

5 changed files with 19 additions and 19 deletions

View File

@ -7,7 +7,7 @@ from .block import *
from .address import *
from .wallet import *
from .crypto import *
from cache_strategies import LRU
# from cache_strategies import LRU
from cache_strategies import MRU
from pybtc.connector import Connector

View File

@ -242,12 +242,12 @@ static PyObject *CACHE_delete(CACHE *self, PyObject *args) {
return instead;
}
Py_INCREF(node->value);
cache_remove_node(self, node);
PyDict_DelItem(self->dict, node->key);
Py_XDECREF(node);
PyObject *return_value = Py_BuildValue("O", node->value);
return return_value;
return node->value;
}
static PyObject *CACHE_set_size(CACHE *self, PyObject *args, PyObject *kwds) {
@ -623,7 +623,7 @@ static PyMethodDef LRU_methods[] = {
static PyTypeObject MRUType = {
PyVarObject_HEAD_INIT(NULL, 0)
"_cache.MRU", /* tp_name */
"cache_strategies.MRU", /* tp_name */
sizeof(CACHE), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)cache_dealloc, /* tp_dealloc */
@ -664,7 +664,7 @@ static PyTypeObject MRUType = {
static PyTypeObject LRUType = {
PyVarObject_HEAD_INIT(NULL, 0)
"_cache.LRU", /* tp_name */
"cache_strategies.LRU", /* tp_name */
sizeof(CACHE), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)cache_dealloc, /* tp_dealloc */
@ -727,14 +727,14 @@ static PyObject *moduleinit(void) {
MRUType.tp_new = PyType_GenericNew;
if (PyType_Ready(&MRUType) < 0) return NULL;
LRUType.tp_new = PyType_GenericNew;
if (PyType_Ready(&MRUType) < 0) return NULL;
// if (PyType_Ready(&LRUType) < 0) return NULL;
m = PyModule_Create(&moduledef);
if (m == NULL) return NULL;
Py_INCREF(&NodeType);
Py_INCREF(&MRUType);
Py_INCREF(&LRUType);
// PyModule_AddObject(m, "MRU", (PyObject *) &MRUType);
PyModule_AddObject(m, "LRU", (PyObject *) &LRUType);
// Py_INCREF(&LRUType);
PyModule_AddObject(m, "MRU", (PyObject *) &MRUType);
// PyModule_AddObject(m, "LRU", (PyObject *) &LRUType);
return m;
}

View File

@ -12,7 +12,7 @@ import traceback
from pybtc.connector.utils import decode_block_tx
import _pickle as pickle
from pybtc import MRU
from pybtc import MRU
class BlockLoader:
@ -209,8 +209,8 @@ class Worker:
self.loop.set_default_executor(ThreadPoolExecutor(20))
self.out_writer = out_writer
self.in_reader = in_reader
self.coins = MRU(100000)
self.destroyed_coins = MRU(100000)
# self.coins = MRU(100000)
# self.destroyed_coins = MRU(100000)
signal.signal(signal.SIGTERM, self.terminate)
self.loop.create_task(self.message_loop())
self.loop.run_forever()
@ -245,10 +245,10 @@ class Worker:
inp = block["rawTx"][z]["vIn"][i]
outpoint = b"".join((inp["txId"], int_to_bytes(inp["vOut"])))
try:
r = self.coins.delete(outpoint)
block["rawTx"][z]["vIn"][i]["_c_"] = r
# r = self.coins.delete(outpoint)
# block["rawTx"][z]["vIn"][i]["_c_"] = r
t += 1
self.destroyed_coins[r[0]] = True
# self.destroyed_coins[r[0]] = True
except:
pass
for i in block["rawTx"][z]["vOut"]:
@ -259,7 +259,7 @@ class Worker:
except:
address = b"".join((bytes([block["rawTx"][z]["vOut"][i]["nType"]]),
block["rawTx"][z]["vOut"][i]["addressHash"]))
self.coins[o] = (pointer, block["rawTx"][z]["vOut"][i]["value"], address)
# self.coins[o] = (pointer, block["rawTx"][z]["vOut"][i]["value"], address)
blocks[x] = block
if blocks:
blocks[x]["checkpoint"] = x
@ -268,12 +268,12 @@ class Worker:
for i in blocks[x]["rawTx"][y]["vOut"]:
try:
pointer = (x << 42) + (y << 21) + i
r = self.destroyed_coins.delete(pointer)
blocks[x]["rawTx"][y]["vOut"][i]["_s_"] = r
# r = self.destroyed_coins.delete(pointer)
# blocks[x]["rawTx"][y]["vOut"][i]["_s_"] = r
except: pass
blocks[x] = pickle.dumps(blocks[x])
self.log.critical("worker [%s]" % self.name)
self.pipe_sent_msg(b'result', pickle.dumps(blocks))
except:
self.pipe_sent_msg(b'result', pickle.dumps([]))