Check the files sqlite_store/notes.rs, store/mod.rs, store/store.sql
first check that all input/output note functions and structs have their own implementation and are not shared between the two
then see the changes of the inner structure of XNoteRecord
Lastly check the other files as almost all (if not all) changes are made to accomodate to the new note record interface
Summary of changes
It splits the InputNoteRecord into InputNoteRecord and OutputNoteRecord structs. While they store similar fields, they support slightly different fields and as discussed on #197, this approach would be more flexible to refactor in the future. As a consecuence, we now have separate:
SerializedInputNoteData and SerializedOutputNoteData
SerializedInputNoteParts and SerializedOutputNoteParts
parse_input_note_columns and parse_output_columns functions
parse_input_note and parse_output_note functions
serialize_input_note and serialize_output_note functions
For both XNoteRecord structs, we replace the Note with its fields as some of them might not be known depending on the flow. As a consecuence:
For some fields we stored String or Vec<u8> since the actual type does not implement serde's Serialize and Deserialize traits. We added the necessary casting. It should be discussed whether we want the interface of the struct to return these String or Vec or we want to return the proper types (perhaps we can keep it as is but add From implementations).
The serialize_X_note, parse_X_note_column and parse_X_note functions are now slightly different since we need to adjust to the new note record fields
Uses of InputNoteRecord in the client and the cli had to be accordingly updated
I also added a Struct for the note status NoteStatus. While it's quite declarative, i don't like that some queries now do for example INSERT ... status = '"Committed"' ... though to account for serde's way of serializing the enum as a json string. Any suggestions are more than welcome
addresses #197. This PR achieves 2 things:
I suggest checking this PR in 3 steps:
sqlite_store/notes.rs
,store/mod.rs
,store/store.sql
XNoteRecord
Summary of changes
InputNoteRecord
intoInputNoteRecord
andOutputNoteRecord
structs. While they store similar fields, they support slightly different fields and as discussed on #197, this approach would be more flexible to refactor in the future. As a consecuence, we now have separate:SerializedInputNoteData
andSerializedOutputNoteData
SerializedInputNoteParts
andSerializedOutputNoteParts
parse_input_note_columns
andparse_output_columns
functionsparse_input_note
andparse_output_note
functionsserialize_input_note
andserialize_output_note
functionsXNoteRecord
structs, we replace theNote
with its fields as some of them might not be known depending on the flow. As a consecuence:String
orVec<u8>
since the actual type does not implement serde'sSerialize
andDeserialize
traits. We added the necessary casting. It should be discussed whether we want the interface of the struct to return theseString
orVec
or we want to return the proper types (perhaps we can keep it as is but addFrom
implementations).serialize_X_note
,parse_X_note_column
andparse_X_note
functions are now slightly different since we need to adjust to the new note record fieldsInputNoteRecord
in the client and the cli had to be accordingly updatedNoteStatus
. While it's quite declarative, i don't like that some queries now do for exampleINSERT ... status = '"Committed"' ...
though to account for serde's way of serializing the enum as a json string. Any suggestions are more than welcome