55[ ![ License] ( https://img.shields.io/crates/l/prollytree.svg )] ( https://github.com/yourusername/prollytree/blob/main/LICENSE )
66[ ![ Downloads] ( https://img.shields.io/crates/d/prollytree.svg )] ( https://crates.io/crates/prollytree )
77
8- A Prolly Tree is a hybrid data structure that combines the features of B-trees and Merkle trees to provide
9- both efficient data access and verifiable integrity. It is specifically designed to handle the requirements
10- of distributed systems and large-scale databases, making indexes syncable and distributable over
8+ A Prolly Tree is a hybrid data structure that combines the features of B-trees and Merkle trees to provide
9+ both efficient data access and verifiable integrity. It is specifically designed to handle the requirements
10+ of distributed systems and large-scale databases, making indexes syncable and distributable over
1111peer-to-peer (P2P) networks.
1212
1313## Key Features
@@ -111,23 +111,23 @@ use prollytree::git::GitVersionedKvStore;
111111fn main () -> Result <(), Box <dyn std :: error :: Error >> {
112112 // Initialize git-backed store
113113 let mut store = GitVersionedKvStore :: init (" ./my-data" )? ;
114-
114+
115115 // Set values (automatically stages changes)
116116 store . set (b " config/api_key" , b " secret123" )? ;
117117 store . set (b " config/timeout" , b " 30" )? ;
118-
118+
119119 // Commit changes
120120 store . commit (" Update API configuration" )? ;
121-
121+
122122 // Create a branch for experiments
123123 store . checkout_new_branch (" feature/new-settings" )? ;
124124 store . set (b " config/timeout" , b " 60" )? ;
125125 store . commit (" Increase timeout" )? ;
126-
126+
127127 // Switch back and see the difference
128128 store . checkout (" main" )? ;
129129 let timeout = store . get (b " config/timeout" )? ; // Returns b"30"
130-
130+
131131 Ok (())
132132}
133133```
@@ -143,23 +143,23 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
143143 // Initialize SQL-capable storage
144144 let storage = ProllyStorage :: <32 >:: init (" ./data" )? ;
145145 let mut glue = Glue :: new (storage );
146-
146+
147147 // Create table and insert data
148148 glue . execute (" CREATE TABLE users (id INTEGER, name TEXT, age INTEGER)" ). await ? ;
149149 glue . execute (" INSERT INTO users VALUES (1, 'Alice', 30)" ). await ? ;
150150 glue . execute (" INSERT INTO users VALUES (2, 'Bob', 25)" ). await ? ;
151-
151+
152152 // Query with SQL
153153 let result = glue . execute (" SELECT * FROM users WHERE age > 26" ). await ? ;
154154 // Returns: [(1, 'Alice', 30)]
155-
155+
156156 // Time travel query (requires commit)
157157 glue . storage. commit (" Initial user data" ). await ? ;
158158 glue . execute (" UPDATE users SET age = 31 WHERE id = 1" ). await ? ;
159-
159+
160160 // Query previous version
161161 let old_data = glue . storage. query_at_commit (" HEAD~1" , " SELECT * FROM users" ). await ? ;
162-
162+
163163 Ok (())
164164}
165165```
@@ -176,19 +176,19 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
176176 let mut memory = AgentMemorySystem :: init_with_thread_safe_git (
177177 " ./agent_memory" , " assistant_001" . to_string (), None
178178 )? ;
179-
179+
180180 // Store conversation in short-term memory
181181 memory . short_term. store_conversation_turn (
182182 " session_123" , " user" , " What's the weather in Tokyo?" , None
183183 ). await ? ;
184-
184+
185185 // Store facts in semantic memory
186186 memory . semantic. store_fact (
187187 " location" , " tokyo" ,
188188 json! ({" timezone" : " JST" , " temp" : " 22°C" }),
189189 0.9 , " weather_api"
190190 ). await ? ;
191-
191+
192192 // Query memories
193193 let query = MemoryQuery {
194194 namespace : None ,
@@ -201,11 +201,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
201201 include_expired : false ,
202202 };
203203 let results = memory . semantic. query (query ). await ? ;
204-
204+
205205 // Create checkpoint
206206 let commit_id = memory . checkpoint (" Weather session" ). await ? ;
207207 println! (" Stored {} memories, checkpoint: {}" , results . len (), commit_id );
208-
208+
209209 Ok (())
210210}
211211```
@@ -219,19 +219,19 @@ use prollytree::storage::InMemoryNodeStorage;
219219fn main () {
220220 let storage = InMemoryNodeStorage :: <32 >:: new ();
221221 let mut tree = ProllyTree :: new (storage , Default :: default ());
222-
222+
223223 // Insert sensitive data
224224 tree . insert (b " balance:alice" . to_vec (), b " 1000" . to_vec ());
225225 tree . insert (b " balance:bob" . to_vec (), b " 500" . to_vec ());
226-
226+
227227 // Generate cryptographic proof
228228 let proof = tree . generate_proof (b " balance:alice" ). unwrap ();
229229 let root_hash = tree . root_hash ();
230-
230+
231231 // Verify proof (can be done by third party)
232232 let is_valid = tree . verify_proof (& proof , b " balance:alice" , b " 1000" );
233233 assert! (is_valid );
234-
234+
235235 // Root hash changes if any data changes
236236 tree . update (b " balance:alice" . to_vec (), b " 1100" . to_vec ());
237237 let new_root = tree . root_hash ();
@@ -249,4 +249,4 @@ Contributions are welcome! Please submit a pull request or open an issue to disc
249249
250250## License
251251
252- This project is licensed under the Apache License 2.0. See the [ LICENSE] ( LICENSE ) file for details.
252+ This project is licensed under the Apache License 2.0. See the [ LICENSE] ( LICENSE ) file for details.
0 commit comments