Blockchain simulator - Sha256 Merkle Tree 12b
The ExSan Abstract Data Structure can be used to implement a complex blockchain structure.
Each ExSan Node can be considered a block in the chain, pointing to a Merkle Binary Tree.
In fact, each ExSan Node can point to any user-defined abstract structure.
1 LEARNING BLOCKCHAIN
2
This a Computer Science topic quite interesting.
3
I have coded my first simulations using ExSan
4
It already has implemented binary tree in every block / node
Wikipedia Merkle Tree
5
This simulations tracks blockchains transactions without hashing.
6
Every row is a peer, when it reaches the end of the row it comes
7
back to the begining of the row and keeps on.
8
COURSERA Bitcoin and Cryptocurrency Technologies
9
ref:
My Profile #opentowork
10
Code and output of the simulation of simple transactions as depicted on the picture above
11
1 THIS IS NOT IMPLEMENTED YET
2 In cryptographyand computer science, a hash tree or Merkle tree is a tree
3 in which every "leaf" (node)is labelled with the cryptographic hash of a
4 data block, and every node that is not a leaf(called a branch, inner node,
5 or inode) is labelled with the cryptographic hash of the labels of its
6 child nodes.A hash tree allows efficientand secure verification of the
7 contents of a large data structure.A hash tree is a generalization of a
8 hash listand a hash chain.
9
10 /////----------------output Merkle Tree
11 JUST HASHING THE KEY VAL OF THE MERKLE TREE
12
13 | ExSan | C++ | ExSan | MSVSC2019_V16_11.23@01.11
14 Sat Feb 11 10:58 : 16 2023
15
16
17 exsan.plusplus@gmail.com https ://twitter.com/#!/ExSan_com
18 JOB: bch6_5816
19
20 Block Chain Simulator 6
21 key is a secuential number, if leaf sha(val in block)
22 if no leave, sha of previous child
23 Generate Exsan(2, 2)
24
25 LEDGER IN EVERY BLOCK - NODE
26
27 33 Insert randNumber : 89 in Block Row : 2 Col : 2
28 Val in Block
29 WORKSHEET 0 @[2, 2] FLOAT
30 A B
31 > ------------------<
32 1: 0 0
33 2 : 0 89
34 < ------------------ >
35
36 Counter block Transactionsin
37 WORKSHEET 0 @[2, 2] PIX
38 A B
39 >------<
40 1: 0 0
41 2 : 0 1
42 < ------ >
43
44 Merkle Tree In Order Traversal of hash string
45 val-> 89 cd70bea023f752a0564abb6ed08d42c1440f2e33e29914e55e0be1595e24f45a
46
47 33 Insert randNumber : 13 in Block Row : 2 Col : 1
48 Val in Block
49 WORKSHEET 0 @[2, 2] FLOAT
50 A B
51 >------------------<
52 1: 0 0
53 2 : 13 89
54 < ------------------ >
55
56 Counter block Transactionsin
57 WORKSHEET 0 @[2, 2] PIX
58 A B
59 >------<
60 1: 0 0
61 2 : 1 1
62 < ------ >
63
64 Merkle Tree In Order Traversal of hash string
65 val-> 13 3fdba35f04dc8c462986c992bcf875546257113072a909c162f7e470e581e278
66
67 33 Insert randNumber : 77 in Block Row : 2 Col : 1
68 Val in Block
69 WORKSHEET 0 @[2, 2] FLOAT
70 A B
71 >------------------<
72 1: 0 0
73 2 : 77 89
74 < ------------------ >
75
76 Counter block Transactionsin
77 WORKSHEET 0 @[2, 2] PIX
78 A B
79 >------<
80 1: 0 0
81 2 : 2 1
82 < ------ >
83
84 Merkle Tree In Order Traversal of hash string
85 val-> 13 3fdba35f04dc8c462986c992bcf875546257113072a909c162f7e470e581e278
86 val-> 77 a88a7902cb4ef697ba0b6759c50e8c10297ff58f942243de19b984841bfe1f73
87
88 33 Insert randNumber : 33 in Block Row : 2 Col : 1
89 Val in Block
90 WORKSHEET 0 @[2, 2] FLOAT
91 A B
92 >------------------<
93 1: 0 0
94 2 : 33 89
95 < ------------------ >
96
97 Counter block Transactionsin
98 WORKSHEET 0 @[2, 2] PIX
99 A B
100 >------<
101 1: 0 0
102 2 : 3 1
103 < ------ >
104
105 Merkle Tree In Order Traversal of hash string
106 val-> 13 3fdba35f04dc8c462986c992bcf875546257113072a909c162f7e470e581e278
107 val-> 77 a88a7902cb4ef697ba0b6759c50e8c10297ff58f942243de19b984841bfe1f73
108 val-> 33 c6f3ac57944a531490cd39902d0f777715fd005efac9a30622d5f5205e7f6894
109
110 33 Insert randNumber : 55 in Block Row : 2 Col : 1
111 Val in Block
112 WORKSHEET 0 @[2, 2] FLOAT
113 A B
114 >------------------<
115 1: 0 0
116 2 : 55 89
117 < ------------------ >
118
119 Counter block Transactionsin
120 WORKSHEET 0 @[2, 2] PIX
121 A B
122 >------<
123 1: 0 0
124 2 : 4 1
125 < ------ >
126
127 Merkle Tree In Order Traversal of hash string
128 val-> 55 02d20bbd7e394ad5999a4cebabac9619732c343a4cac99470c03e23ba2bdc2bc
129 val-> 13 3fdba35f04dc8c462986c992bcf875546257113072a909c162f7e470e581e278
130 val-> 77 a88a7902cb4ef697ba0b6759c50e8c10297ff58f942243de19b984841bfe1f73
131 val-> 33 c6f3ac57944a531490cd39902d0f777715fd005efac9a30622d5f5205e7f6894
132
133 33 Insert randNumber : 91 in Block Row : 2 Col : 2
134 Val in Block
135 WORKSHEET 0 @[2, 2] FLOAT
136 A B
137 >------------------<
138 1: 0 0
139 2 : 55 91
140 < ------------------ >
141
142 Counter block Transactionsin
143 WORKSHEET 0 @[2, 2] PIX
144 A B
145 >------<
146 1: 0 0
147 2 : 4 2
148 < ------ >
149
150 Merkle Tree In Order Traversal of hash string
151 val-> 91 1da51b8d8ff98f6a48f80ae79fe3ca6c26e1abb7b7d125259255d6d2b875ea08
152 val-> 89 cd70bea023f752a0564abb6ed08d42c1440f2e33e29914e55e0be1595e24f45a
153
154 33 Insert randNumber : 47 in Block Row : 1 Col : 2
155 Val in Block
156 WORKSHEET 0 @[2, 2] FLOAT
157 A B
158 >------------------<
159 1: 0 47
160 2 : 55 91
161 < ------------------ >
162
163 Counter block Transactionsin
164 WORKSHEET 0 @[2, 2] PIX
165 A B
166 >------<
167 1: 0 1
168 2 : 4 2
169 < ------ >
170
171 Merkle Tree In Order Traversal of hash string
172 val-> 47 31489056e0916d59fe3add79e63f095af3ffb81604691f21cad442a85c7be617
173
174 33 Insert randNumber : 54 in Block Row : 2 Col : 2
175 Val in Block
176 WORKSHEET 0 @[2, 2] FLOAT
177 A B
178 >------------------<
179 1: 0 47
180 2 : 55 54
181 < ------------------ >
182
183 Counter block Transactionsin
184 WORKSHEET 0 @[2, 2] PIX
185 A B
186 >------<
187 1: 0 1
188 2 : 4 3
189 < ------ >
190
191 Merkle Tree In Order Traversal of hash string
192 val-> 91 1da51b8d8ff98f6a48f80ae79fe3ca6c26e1abb7b7d125259255d6d2b875ea08
193 val-> 54 2fca346db656187102ce806ac732e06a62df0dbb2829e511a770556d398e1a6e
194 val-> 89 cd70bea023f752a0564abb6ed08d42c1440f2e33e29914e55e0be1595e24f45a
195
196 33 Insert randNumber : 79 in Block Row : 2 Col : 2
197 Val in Block
198 WORKSHEET 0 @[2, 2] FLOAT
199 A B
200 >------------------<
201 1: 0 47
202 2 : 55 79
203 < ------------------ >
204
205 Counter block Transactionsin
206 WORKSHEET 0 @[2, 2] PIX
207 A B
208 >------<
209 1: 0 1
210 2 : 4 4
211 < ------ >
212
213 Merkle Tree In Order Traversal of hash string
214 val-> 91 1da51b8d8ff98f6a48f80ae79fe3ca6c26e1abb7b7d125259255d6d2b875ea08
215 val-> 54 2fca346db656187102ce806ac732e06a62df0dbb2829e511a770556d398e1a6e
216 val-> 79 98a3ab7c340e8a033e7b37b6ef9428751581760af67bbab2b9e05d4964a8874a
217 val-> 89 cd70bea023f752a0564abb6ed08d42c1440f2e33e29914e55e0be1595e24f45a
218
219 33 Insert randNumber : 73 in Block Row : 1 Col : 1
220 Val in Block
221 WORKSHEET 0 @[2, 2] FLOAT
222 A B
223 >------------------<
224 1: 73 47
225 2 : 55 79
226 < ------------------ >
227
228 Counter block Transactionsin
229 WORKSHEET 0 @[2, 2] PIX
230 A B
231 >------<
232 1: 1 1
233 2 : 4 4
234 < ------ >
235
236
237
238 .... more here
239
240
241 33 Insert randNumber : 41 in Block Row : 2 Col : 1
242 Val in Block
243 WORKSHEET 0 @[2, 2] FLOAT
244 A B
245 > ------------------<
246 1: 3 59
247 2: 41 14
248 < ------------------ >
249
250 Counter block Transactionsin
251 WORKSHEET 0 @[2, 2] PIX
252 A B
253 >------ <
254 1: 4 5
255 2: 11 9
256 < ------ >
257
258 Merkle Tree In Order Traversal of hash string
259 val-> 55 02d20bbd7e394ad5999a4cebabac9619732c343a4cac99470c03e23ba2bdc2bc
260 val-> 91 1da51b8d8ff98f6a48f80ae79fe3ca6c26e1abb7b7d125259255d6d2b875ea08
261 val-> 8 2c624232cdd221771294dfbb310aca000a0df6ac8b66b696d90ef06fdefb64a3
262 val-> 47 31489056e0916d59fe3add79e63f095af3ffb81604691f21cad442a85c7be617
263 val-> 41 3d914f9348c9cc0ff8a79716700b9fcd4d2f3e711608004eb8f138bcba7f14d9
264 val-> 13 3fdba35f04dc8c462986c992bcf875546257113072a909c162f7e470e581e278
265 val-> 42 73475cb40a568e8da8a045ced110137e159f890ac4da883b6b17dc651b3a8049
266 val-> 73 96061e92f58e4bdcdee73df36183fe3ac64747c81c26f6c83aada8d2aabb1864
267 val-> 77 a88a7902cb4ef697ba0b6759c50e8c10297ff58f942243de19b984841bfe1f73
268 val-> 85 b4944c6ff08dc6f43da2e9c824669b7d927dd1fa976fadc7b456881f51bf5ccc
269 val-> 33 c6f3ac57944a531490cd39902d0f777715fd005efac9a30622d5f5205e7f6894
270
271 33 Insert randNumber : 43 in Block Row : 2 Col : 2
272 Val in Block
273 WORKSHEET 0 @[2, 2] FLOAT
274 A B
275 > ------------------<
276 1: 3 59
277 2: 41 43
278 < ------------------ >
279
280 Counter block Transactionsin
281 WORKSHEET 0 @[2, 2] PIX
282 A B
283 >------ <
284 1: 4 5
285 2 : 11 10
286 < ------ >
287
288 Merkle Tree In Order Traversal of hash string
289 val-> 91 1da51b8d8ff98f6a48f80ae79fe3ca6c26e1abb7b7d125259255d6d2b875ea08
290 val-> 8 2c624232cdd221771294dfbb310aca000a0df6ac8b66b696d90ef06fdefb64a3
291 val-> 54 2fca346db656187102ce806ac732e06a62df0dbb2829e511a770556d398e1a6e
292 val-> 43 44cb730c420480a0477b505ae68af508fb90f96cf0ec54c6ad16949dd427f13a
293 val-> 23 535fa30d7e25dd8a49f1536779734ec8286108d115da5045d77f3b4185d8f790
294 val-> 14 8527a891e224136950ff32ca212b45bc93f69fbb801c3b1ebedac52775f99e61
295 val-> 73 96061e92f58e4bdcdee73df36183fe3ac64747c81c26f6c83aada8d2aabb1864
296 val-> 79 98a3ab7c340e8a033e7b37b6ef9428751581760af67bbab2b9e05d4964a8874a
297 val-> 95 ad48ff99415b2f007dc35b7eb553fd1eb35ebfa2f2f308acd9488eeb86f71fa8
298 val-> 89 cd70bea023f752a0564abb6ed08d42c1440f2e33e29914e55e0be1595e24f45a
299
300 33 Insert randNumber : 39 in Block Row : 1 Col : 2
301 Val in Block
302 WORKSHEET 0 @[2, 2] FLOAT
303 A B
304 > ------------------<
305 1: 3 39
306 2: 41 43
307 < ------------------ >
308
309 Counter block Transactionsin
310 WORKSHEET 0 @[2, 2] PIX
311 A B
312 >------<
313 1: 4 6
314 2 : 11 10
315 < ------ >
316
317 Merkle Tree In Order Traversal of hash string
318 val-> 39 0b918943df0962bc7a1824c0555a389347b4febdc7cf9d1254406d80ce44e3f9
319 val-> 8 2c624232cdd221771294dfbb310aca000a0df6ac8b66b696d90ef06fdefb64a3
320 val-> 47 31489056e0916d59fe3add79e63f095af3ffb81604691f21cad442a85c7be617
321 val-> 59 3e1e967e9b793e908f8eae83c74dba9bcccce6a5535b4b462bd9994537bfe15c
322 val-> 3 4e07408562bedb8b60ce05c1decfe3ad16b72230967de01f640b7e4729b49fce
323 val-> 85 b4944c6ff08dc6f43da2e9c824669b7d927dd1fa976fadc7b456881f51bf5ccc
324
325 33 Insert randNumber : 26 in Block Row : 2 Col : 2
326 Val in Block
327 WORKSHEET 0 @[2, 2] FLOAT
328 A B
329 >------------------<
330 1: 3 39
331 2 : 41 26
332 < ------------------ >
333
334 Counter block Transactionsin
335 WORKSHEET 0 @[2, 2] PIX
336 A B
337 >------ <
338 1: 4 6
339 2 : 11 11
340 < ------ >
341
342 Merkle Tree In Order Traversal of hash string
343 val-> 91 1da51b8d8ff98f6a48f80ae79fe3ca6c26e1abb7b7d125259255d6d2b875ea08
344 val-> 8 2c624232cdd221771294dfbb310aca000a0df6ac8b66b696d90ef06fdefb64a3
345 val-> 54 2fca346db656187102ce806ac732e06a62df0dbb2829e511a770556d398e1a6e
346 val-> 43 44cb730c420480a0477b505ae68af508fb90f96cf0ec54c6ad16949dd427f13a
347 val-> 23 535fa30d7e25dd8a49f1536779734ec8286108d115da5045d77f3b4185d8f790
348 val-> 26 5f9c4ab08cac7457e9111a30e4664920607ea2c115a1433d7be98e97e64244ca
349 val-> 14 8527a891e224136950ff32ca212b45bc93f69fbb801c3b1ebedac52775f99e61
350 val-> 73 96061e92f58e4bdcdee73df36183fe3ac64747c81c26f6c83aada8d2aabb1864
351 val-> 79 98a3ab7c340e8a033e7b37b6ef9428751581760af67bbab2b9e05d4964a8874a
352 val-> 95 ad48ff99415b2f007dc35b7eb553fd1eb35ebfa2f2f308acd9488eeb86f71fa8
353 val-> 89 cd70bea023f752a0564abb6ed08d42c1440f2e33e29914e55e0be1595e24f45a
354
355 33 Insert randNumber : 82 in Block Row : 1 Col : 1
356 Val in Block
357 WORKSHEET 0 @[2, 2] FLOAT
358 A B
359 > ------------------<
360 1: 82 39
361 2 : 41 26
362 < ------------------ >
363
364 Counter block Transactionsin
365 WORKSHEET 0 @[2, 2] PIX
366 A B
367 >------<
368 1: 5 6
369 2 : 11 11
370 < ------ >
371
372 Merkle Tree In Order Traversal of hash string
373 val-> 17 4523540f1504cd17100c4835e85b7eefd49911580f8efff0599a8f283be6b9e3
374 val-> 3 4e07408562bedb8b60ce05c1decfe3ad16b72230967de01f640b7e4729b49fce
375 val-> 73 96061e92f58e4bdcdee73df36183fe3ac64747c81c26f6c83aada8d2aabb1864
376 val-> 82 a46e37632fa6ca51a13fe39a567b3c23b28c2f47d8af6be9bd63e030e214ba38
377 val-> 57 c837649cce43f2729138e72cc315207057ac82599a59be72765a477f22d14a54
378
379 33 Insert randNumber : 65 in Block Row : 1 Col : 2
380 Val in Block
381 WORKSHEET 0 @[2, 2] FLOAT
382 A B
383 >------------------<
384 1: 82 65
385 2: 41 26
386 <------------------ >
387
388 Counter block Transactionsin
389 WORKSHEET 0 @[2, 2] PIX
390 A B
391 >------<
392 1: 5 7
393 2 : 11 11
394 < ------ >
395
396 Merkle Tree In Order Traversal of hash string
397 val-> 39 0b918943df0962bc7a1824c0555a389347b4febdc7cf9d1254406d80ce44e3f9
398 val-> 65 108c995b953c8a35561103e2014cf828eb654a99e310f87fab94c2f4b7d2a04f
399 val-> 8 2c624232cdd221771294dfbb310aca000a0df6ac8b66b696d90ef06fdefb64a3
400 val-> 47 31489056e0916d59fe3add79e63f095af3ffb81604691f21cad442a85c7be617
401 val-> 59 3e1e967e9b793e908f8eae83c74dba9bcccce6a5535b4b462bd9994537bfe15c
402 val-> 3 4e07408562bedb8b60ce05c1decfe3ad16b72230967de01f640b7e4729b49fce
403 val-> 85 b4944c6ff08dc6f43da2e9c824669b7d927dd1fa976fadc7b456881f51bf5ccc
404 Val in Block pp 0
405 WORKSHEET 0 @[2, 2] FLOAT
406 A B
407 >------------------<
408 1: 82 65
409 2: 41 26
410 < ------------------ >
411
412 Counter in Block pp 0
413 WORKSHEET 0 @[2, 2] PIX
414 A B
415 >------<
416 1: 5 7
417 2: 11 11
418 < ------ >
419
420 hash table 0
421 WORKSHEET 0 @[2, 2] STRING
422 A B
423 >---------------------------------------------------------- <
424 1: a46e376...bd63e030e214ba38 108c995...f87fab94c2f4b7d2a04f
425 2: 3d914f9...b8f138bcba7f14d9 5f9c4ab...433d7be98e97e64244ca
426 <---------------------------------------------------------->
427
428 Final Merkel Tree in each block
429
430 ENDS bch6_5816 Elapsed Time : 1.367 sec
431 Boost version : 1.80.0
432
433 EXIT FROM EXSAN
434
Polulating ExSan with Market Data Tick by Tick
Previous
Low Latency Systematic Trading Algorithm
Next
+
+
C
E
x
S
a
n
C
+
+
D
o
N
o
t
A
c
c
e
p
t
D
e
f
a
u
l
t
s
T
h
i
n
k
D
i
f
f
e
r
e
n
t
Comments
Post a Comment