-
Notifications
You must be signed in to change notification settings - Fork 14
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
Address table #1
Comments
While I agree with you @WhoSoup, I believe this is the table format that Adam agreed with. I will have to dig up the conversion and the rational. |
Using this format means we have to generate on-demand sql queries instead of being able to use prepared statements, since our list of currencies is mutable. We'd also have the table definition change over time so the table creation query itself has to be mutable. That would break with the standards (and particularly db verification) of FATd, so I'd really like @AdamSLevy to take a look at this. |
@sambarnes Do you remember that convo with Admin? |
@Emyrk Really wasn't that long of a conversation. Was in the FAT Integration DM:
I don't really have a strong opinion. This was just quick and dirty to get up and running and let us start populating balances. I don't imagine we'll be adding/removing assets while pegnetd is a thing, but that might happen later (months down the line) when we're in FATd already. We should definitely use the route you suggest at that point in time And like I said, I've been in nosql land for a few years now and haven't been thinking in SQL. So if you think its not the way to go @WhoSoup then I trust your judgement. We already have that mapping you mention as iotas in |
I think for the current daemon, either option will work. I am leaning towards the, "it's implemented, so let's just stick with it for now" |
I believe what @WhoSoup suggested is the proper SQL fully normalized way of approaching this problem. It allows for more dynamically adding more currencies over time without a schema change. He is also right that hard coding the currencies to columns limits the ability to use fully prepared statements. It will become important to control when currencies become accepted by the network, so with this approach I also recommend adding an activation height column to the currencies/assets table. These are things I didn't think about when we had this brief discussion earlier. Of course the other thing to keep in mind is that it would be wise to keep the normalized ids for currencies match the values chosen for the golang ticker type that describes the type of asset: https://github.com/Factom-Asset-Tokens/fatd/blob/9287bc808c49019296d455109e96f34ba521c6a2/fat/fat2/pticker.go#L6-L40 On the other hand, hard coding the currencies as columns is simpler (sort of) and it sounds like its done. A couple notes on fatd. Currently I validate the database schema extremely rigorously when I open connections. In fact schemas that are actually identical but have differing whitespace will fail this validation. I don't believe it was a good design choice long term and I plan to change this to just checking schema_version and user_version and let any schema errors that misses come up when the query occurs. Additionally, while trying to avoid schema changes is a good design goal, it's not ultimately feasible indefinitely. I expect to need to add a migration mechanism for fatd. Sub modules like FAT token types or PEG net may need to be able to apply their own custom migrations when databases are opened. |
Just saw the following:
pegnetd/node/pegnet/addresses.go
Lines 8 to 72 in dd4aec9
That defeats the whole purpose of using relational databases in the first place. You have to add/remove columns to modify the assets (leading to data loss and backward incompatibility) and you can't run automated queries. This is what k-v dbs are for.
The SQL way of doing it would be three tables:
that would let us remove assets without having to remove records from the database and also allow easier comparative queries, like querying a list of assets sorted by their supply
The text was updated successfully, but these errors were encountered: