Skip to content

Commit 490fa4e

Browse files
authored
restructure core data structure to support primitive stump/stubs (#10)
1 parent 5d80a2f commit 490fa4e

File tree

8 files changed

+507
-125
lines changed

8 files changed

+507
-125
lines changed

CHANGELOG

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
The purpose of this changelog is to document new features and breaking changes that are most likely to affect developers
33
------------------------------------------------------------------------------------------------------------------------
44

5+
--- v1.0.4 (2025.09.14) ---
6+
7+
- Modify core merkle tree structure to support "stumps" and branch digest propogation
8+
- Implement sync-stub and sync-cut s7 primitives to work with stumps
9+
- Consolidate sync-pair? and sync-null? into a more general sync-node? type
10+
511
--- v1.0.3 (2025.08.25) ---
612

713
- Add caching mechanism that enforces exactly one unique request per second

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "journal-sdk"
3-
version = "1.0.3"
3+
version = "1.0.4"
44
edition = "2021"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

lisp/blockchain.scm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
(define (sync-caddr x) (sync-car (sync-cdr (sync-cdr x))))
2424

2525
(define (sync-null-pair? x)
26-
(and (sync-pair? x) (sync-null? x)))
26+
(and (sync-node? x) (sync-null? x)))
2727

2828
(define (sync-leaf? x) (and (not (sync-null-pair? x)) (equal? (sync-car x) (sync-cdr x))))
2929

lisp/evaluator.scm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
;; --- verifiable map ---
55

66
(define (nth-bit x n)
7-
(zero? (logand (byte-vector-ref (sync-pair->byte-vector x) (floor (/ n 8)))
7+
(zero? (logand (byte-vector-ref (sync-digest x) (floor (/ n 8)))
88
(ash 1 (modulo n 8)))))
99

1010
(define (sync-caar x) (sync-car (sync-car x)))
@@ -95,11 +95,11 @@
9595
(define (meta-find sp)
9696
(let ((a-find (lambda (x) (byte-vector->expression x))))
9797
(let p-find ((sp sp))
98-
(if (sync-pair? (sync-car sp))
98+
(if (sync-node? (sync-car sp))
9999
(cons (p-find (sync-car sp)) (p-find (sync-cdr sp)))
100100
(let ((type (a-find (sync-car sp)))
101101
(value-sp (sync-cdr sp)))
102-
(let ((value (if (sync-pair? value-sp) (p-find value-sp) (a-find value-sp))))
102+
(let ((value (if (sync-node? value-sp) (p-find value-sp) (a-find value-sp))))
103103
(case type
104104
((procedure?) (eval value))
105105
(else value))))))))

lisp/rdf.scm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
(define (sync-cddr x) (sync-cdr (sync-cdr x)))
1717

1818
(define (sync-null-pair? x)
19-
(and (sync-pair? x) (sync-null? x)))
19+
(and (sync-node? x) (sync-null? x)))
2020

2121
(define (sync-leaf? x) (and (not (sync-null-pair? x)) (equal? (sync-car x) (sync-cdr x))))
2222

src/evaluator.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,15 @@ fn primitive_byte_vector_to_expression() -> Primitive {
223223
bytes.push(s7_byte_vector_ref(arg, i))
224224
}
225225
bytes.push(0);
226-
let c_string =
227-
CString::from_vec_with_nul(bytes).expect("Invalid C string: missing null terminator");
228-
s7_eval_c_string(sc, c_string.as_ptr())
226+
227+
match CString::from_vec_with_nul(bytes) {
228+
Ok(c_string) => s7_eval_c_string(sc, c_string.as_ptr()),
229+
Err(_) => s7_error(
230+
sc,
231+
s7_make_symbol(sc, c"encoding-error".as_ptr()),
232+
s7_list(sc, 1, s7_make_string(sc, c"Byte vector string is malformed".as_ptr()))
233+
)
234+
}
229235
}
230236

231237
Primitive::new(

0 commit comments

Comments
 (0)