Skip to content

Commit 20b6265

Browse files
AmozPayAmozPay
AmozPay
authored and
AmozPay
committed
add iterative image building
1 parent 262d11b commit 20b6265

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/aleph_client/docker/image.py

+17
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,23 @@ def recursive_compute_chain_id(index: int) -> str:
7474
chain_ids.append(chain_id)
7575
return chain_id
7676

77+
78+
79+
# TODO: test this iterative version
80+
iterative_chain_ids = []
81+
def iterative_compute_chain_id(index: int) -> str:
82+
diff_id = self.diff_ids[0]
83+
iterative_chain_ids.append(diff_id)
84+
i = 1
85+
while i < index:
86+
chain_id = "sha256:" + sha256(
87+
iterative_chain_ids[i - 1].encode()
88+
+ " ".encode()
89+
+ self.diff_ids[i].encode()
90+
).hexdigest()
91+
iterative_chain_ids.append(chain_id)
92+
return
93+
7794
recursive_compute_chain_id(len(self.layers_ids) - 1)
7895

7996
return chain_ids

0 commit comments

Comments
 (0)