From 54a1fa9abec52a747ea47bf73c679a7b2f2bef11 Mon Sep 17 00:00:00 2001 From: Diederik Loerakker Date: Sat, 15 Jun 2019 20:57:22 +0200 Subject: [PATCH] Update test_libs/pyspec/eth2spec/utils/ssz/ssz_impl.py Co-Authored-By: vbuterin --- test_libs/pyspec/eth2spec/utils/ssz/ssz_impl.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test_libs/pyspec/eth2spec/utils/ssz/ssz_impl.py b/test_libs/pyspec/eth2spec/utils/ssz/ssz_impl.py index 1a556bc7d..ed8dbf1e0 100644 --- a/test_libs/pyspec/eth2spec/utils/ssz/ssz_impl.py +++ b/test_libs/pyspec/eth2spec/utils/ssz/ssz_impl.py @@ -153,7 +153,13 @@ def item_length(typ): return typ.byte_len else: return 32 - +def chunk_count(typ): + if is_basic_type(typ): + return 1 + elif is_list_kind(typ) or is_vector_kind(typ): + return (typ.length * item_length(typ.elem_type) + 31) // 32 + else: + return len(typ.get_fields()) def hash_tree_root(obj, typ): if is_bottom_layer_kind(typ):