MCPcopy Create free account
hub / github.com/Chia-Network/clvm / get

Method get

clvm/object_cache.py:37–54  ·  view source on GitHub ↗
(self, obj: CLVMStorage)

Source from the content-addressed store, hash-verified

35 self.lookup: Dict[int, Tuple[T, CLVMStorage]] = dict()
36
37 def get(self, obj: CLVMStorage) -> T:
38 obj_id = id(obj)
39 if obj_id not in self.lookup:
40 obj_list = [obj]
41 while obj_list:
42 node = obj_list.pop()
43 node_id = id(node)
44 if node_id not in self.lookup:
45 v = self.f(self, node)
46 if v is None:
47 if node.pair is None:
48 raise ValueError("f returned None for atom", node)
49 obj_list.append(node)
50 obj_list.append(node.pair[0])
51 obj_list.append(node.pair[1])
52 else:
53 self.lookup[node_id] = (v, node)
54 return self.lookup[obj_id][0]
55
56 def contains(self, obj: CLVMStorage) -> bool:
57 return id(obj) in self.lookup

Callers 8

checkMethod · 0.95
test_variousMethod · 0.95
find_pathsMethod · 0.80
treehashFunction · 0.80
serialized_lengthFunction · 0.80
operators_for_dictFunction · 0.80
__call__Method · 0.80

Calls 1

popMethod · 0.80

Tested by 2

checkMethod · 0.76
test_variousMethod · 0.76