-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update storage to support on-chain notes #288
Comments
@bobbinth, regarding Approach 1: we add a If we take the example of this PR it adds a new table for on-chain accounts called |
Ah - good point! I think we should be consistent and either put everything into a single field in the @polydez - what do you think? |
@bobbinth @phklive I personally like the "progressive JPEG method" of development, i.e. implementing of simple approach first and make it more and more complex and sophisticated later. I think, one day we would decide to rewrite our storage completely, so the best approach for now is the simplest one. It could help us to go faster to public testnet and we will be able to make our storage better fit to real data we observe on testnet (for example, how often common scripts will be used in real network). Regarding the issue #293: I think, we're moving to the same 1st approach now during review, so, it will be eventually consistent with notes storage design. :) |
closed by #300 |
This is needed to support on-chain notes, which require storing full
Note
objects in the database. There are several ways to do:Approach 1
Add
details
field to thenotes
table. This field will contain serialized of theNote
object. For now, this will include the metadata - but once we remove it from theNote
, it will be justscript
,inputs
,assets
, andserial_num
. Thedetails
field would be nullable - so, for off-chain notes it will be set to NULL.A potential downside of this approach is that for standardized scripts, we'll be duplicating bunch of data.
Approach 2
Similar to approach 1 (i.e., we add
details
field to thenotes
table), but now we serialize theNote
in such a way that we serialize onlyinputs
,assets
,serial_num
, andscript_root
. The actual script would be stored in a new table -note_scripts
, which could look as follows:This would avoid script duplication for common scripts, but may make lookups a bit more involved.
Approach 3
Add a separate table for
note_details
which would havenote_id
as the primary key and would have all fields (script
,inputs
,assets
, andserial_num
) materialized. Similar to approach 2, we could also have a separate table fornote_scripts
to reduce storage footprint.The advantage of this approach is that it completely separates note details from the original note table - so, we could imagine
note_details
living on a separate disk in the future.Overall, my thinking is that approach 1 is probably the simplest to go with for now and then we can get more sophisticated in the future with either approach 2 or 3.
The text was updated successfully, but these errors were encountered: