Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Commit 25753d2

Browse files
committed
rm: unused utils
1 parent a446d68 commit 25753d2

File tree

3 files changed

+6
-85
lines changed

3 files changed

+6
-85
lines changed

.coveragerc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ omit =
88
*/fixtures/*
99
*/tests/*
1010
*/utils/*
11+
*/ethereum/fastvm.py
12+
*/ethereum/spv.py
1113

1214
[report]
1315
exclude_lines =

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ help:
88
@echo "lint - check style with flake8"
99
@echo "test - run tests with the default Python"
1010
@echo "testnovm - run tests except test_vm"
11+
@echo "testquick - run tests except test_vm, test_state"
1112
@echo "testtb - run tests with tracebacks"
1213
@echo "test-all - run tests on every Python version with tox"
1314
@echo "coverage - check code coverage quickly with the default Python"
@@ -42,6 +43,9 @@ test:
4243
testnovm:
4344
py.test --tb=no ethereum/tests/ --ignore=ethereum/tests/test_vm.py
4445

46+
testquick:
47+
py.test --tb=no ethereum/tests/ --ignore=ethereum/tests/test_vm.py --ignore=ethereum/tests/test_state.py
48+
4549
testtb:
4650
python setup.py test
4751

ethereum/utils.py

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -166,30 +166,6 @@ def sha3rlp(x):
166166
return sha3(rlp.encode(x))
167167

168168

169-
def int_to_big_endian4(integer):
170-
''' 4 bytes big endian integer'''
171-
return struct.pack('>I', integer)
172-
173-
174-
def recursive_int_to_big_endian(item):
175-
''' convert all int to int_to_big_endian recursively
176-
'''
177-
if is_numeric(item):
178-
return big_endian_int.serialize(item)
179-
elif isinstance(item, (list, tuple)):
180-
res = []
181-
for item in item:
182-
res.append(recursive_int_to_big_endian(item))
183-
return res
184-
return item
185-
186-
187-
def rlp_encode(item):
188-
'''
189-
item can be nested string/integer/list of string/integer
190-
'''
191-
return rlp.encode(recursive_int_to_big_endian(item))
192-
193169
# Format encoders/decoders for bin, addr, int
194170

195171

@@ -214,18 +190,6 @@ def decode_int(v):
214190
return big_endian_to_int(v)
215191

216192

217-
def decode_root(root):
218-
if isinstance(root, list):
219-
if len(rlp.encode(root)) >= 32:
220-
raise Exception("Direct RLP roots must have length <32")
221-
elif is_string(root):
222-
if len(root) != 0 and len(root) != 32:
223-
raise Exception("String roots must be empty or length-32")
224-
else:
225-
raise Exception("Invalid root")
226-
return root
227-
228-
229193
def decode_int256(v):
230194
return big_endian_to_int(v)
231195

@@ -240,13 +204,6 @@ def encode_root(v):
240204
return v
241205

242206

243-
def encode_addr(v):
244-
'''encodes an address into serialization'''
245-
if not is_string(v) or len(v) not in [0, 40]:
246-
raise Exception("Address must be empty or 40 chars long")
247-
return decode_hex(v)
248-
249-
250207
def encode_int(v):
251208
'''encodes an integer into serialization'''
252209
if not is_numeric(v) or v < 0 or v >= TT256:
@@ -277,14 +234,12 @@ def scan_int(v):
277234
"bin": decode_bin,
278235
"addr": decode_addr,
279236
"int": decode_int,
280-
"trie_root": decode_root,
281237
"int256b": decode_int256,
282238
}
283239

284240
# Encoding to RLP serialization
285241
encoders = {
286242
"bin": encode_bin,
287-
"addr": encode_addr,
288243
"int": encode_int,
289244
"trie_root": encode_root,
290245
"int256b": encode_int256,
@@ -361,46 +316,6 @@ def wrapper(*args, **kwargs):
361316
return inner
362317

363318

364-
class DataDir(object):
365-
366-
ethdirs = {
367-
"linux2": "~/.pyethereum",
368-
"darwin": "~/Library/Application Support/Pyethereum/",
369-
"win32": "~/AppData/Roaming/Pyethereum",
370-
"win64": "~/AppData/Roaming/Pyethereum",
371-
}
372-
373-
def __init__(self):
374-
self._path = None
375-
376-
def set(self, path):
377-
path = os.path.abspath(path)
378-
if not os.path.exists(path):
379-
os.makedirs(path)
380-
assert os.path.isdir(path)
381-
self._path = path
382-
383-
def _set_default(self):
384-
p = self.ethdirs.get(sys.platform, self.ethdirs['linux2'])
385-
self.set(os.path.expanduser(os.path.normpath(p)))
386-
387-
@property
388-
def path(self):
389-
if not self._path:
390-
self._set_default()
391-
return self._path
392-
393-
#data_dir = DataDir()
394-
395-
default_data_dir = DataDir().path
396-
397-
398-
def db_path(data_dir):
399-
if not os.path.exists(data_dir):
400-
os.makedirs(data_dir)
401-
return os.path.join(data_dir, 'statedb')
402-
403-
404319
def dump_state(trie):
405320
res = ''
406321
for k, v in list(trie.to_dict().items()):

0 commit comments

Comments
 (0)