Datasets:
Mirror from SNAPKITTYWEST: examples/treasury.m
Browse files- examples/treasury.m +18 -0
examples/treasury.m
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# treasury.m — multi-step ledger chain
|
| 2 |
+
|
| 3 |
+
@deterministic
|
| 4 |
+
define hash_record(id, account, amount, prev_hex)
|
| 5 |
+
begin
|
| 6 |
+
let id_b = integer_to_bytes(id, 8)
|
| 7 |
+
let acc_b = integer_to_bytes(account, 8)
|
| 8 |
+
let amt_b = integer_to_bytes(amount, 16)
|
| 9 |
+
let prev_b = hex_to_bytes(prev_hex)
|
| 10 |
+
let msg = concat(id_b, concat(acc_b, concat(amt_b, prev_b)))
|
| 11 |
+
return sha256_hex(msg)
|
| 12 |
+
end
|
| 13 |
+
|
| 14 |
+
const GENESIS = "0000000000000000000000000000000000000000000000000000000000000000"
|
| 15 |
+
|
| 16 |
+
const h1 = hash_record(1, 1001, 50000, GENESIS)
|
| 17 |
+
const h2 = hash_record(2, 1002, 75000, h1)
|
| 18 |
+
const h3 = hash_record(3, 1001, 20000, h2)
|