-
Notifications
You must be signed in to change notification settings - Fork 20
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
Use sqlite3 for persistent storage #143
Comments
I have recently read this article on mozilla's wiki: Maybe a compressed json file could be better than an sqlite3 database in our case, after all? |
What size is the database, what do you store there? Is there some sample, or where is the relevant code? |
Ah you are right, some answers are required here. Roughly, the database size equals: The database code is inside the database component: The top level data structure that is being stored inside the database is Example node database
{
"funder_state": {
"local_public_key": "bg0YXCoK02mfBUPqtFcjUDU0yqCFJjgOvyjGU-D2YLA",
"relays": [
{
"publicKey": "_5BaZ-NnRpyCimUc_erW_Tzv9xyUiz-Y2zWglJmFNxA",
"address": "relay2.offsetcredit.org:11056",
"name": "relay2"
}
],
"friends": {
"Zbt-_YWgmqNCYE1AZLJNFsmuEYBvYyI3TX2FgUvljpE": {
"local_public_key": "bg0YXCoK02mfBUPqtFcjUDU0yqCFJjgOvyjGU-D2YLA",
"remote_public_key": "Zbt-_YWgmqNCYE1AZLJNFsmuEYBvYyI3TX2FgUvljpE",
"remote_relays": [
{
"publicKey": "9F_0d1ZVeyYYS9tpVnkUtjtCePcH-_hRWdbduNL_X04",
"address": "relay1.offsetcredit.org:11156"
}
],
"sent_local_relays": {
"LastSent": [
{
"publicKey": "_5BaZ-NnRpyCimUc_erW_Tzv9xyUiz-Y2zWglJmFNxA",
"address": "relay2.offsetcredit.org:11056",
"name": "relay2"
}
]
},
"name": "desktop_right",
"currency_configs": {
"ILS": {
"rate": {
"mul": 0,
"add": 0
},
"remote_max_debt": "1000",
"is_open": true
}
},
"status": "Enabled",
"channel_status": {
"Consistent": {
"token_channel": {
"direction": {
"Incoming": {
"move_token_in": {
"prefix_hash": "6A8js4G09gGiI5tY3aMYBEcuiQFVfHZCUMcWyblbEQU",
"token_info": {
"mc": {
"local_public_key": "Zbt-_YWgmqNCYE1AZLJNFsmuEYBvYyI3TX2FgUvljpE",
"remote_public_key": "bg0YXCoK02mfBUPqtFcjUDU0yqCFJjgOvyjGU-D2YLA",
"balances": [
{
"currency": "ILS",
"balance_info": {
"balance": "-250",
"local_pending_debt": "0",
"remote_pending_debt": "0"
}
}
]
},
"counters": {
"inconsistency_counter": 0,
"move_token_counter": "47"
}
},
"rand_nonce": "Az_KGmn5P7be31jIS2wyBw",
"new_token": "59aEIZJOMEjMPTCnKRKA57rmmhVCZ0lNqFlyrcIPiTcWHrJ-tBngJVjs33Jn-S98V3OWv-uoUSkPr8fOFzyeDg"
}
}
},
"mutual_credits": {
"ILS": {
"state": {
"idents": {
"local_public_key": "bg0YXCoK02mfBUPqtFcjUDU0yqCFJjgOvyjGU-D2YLA",
"remote_public_key": "Zbt-_YWgmqNCYE1AZLJNFsmuEYBvYyI3TX2FgUvljpE"
},
"currency": "ILS",
"balance": {
"balance": "250",
"local_pending_debt": "0",
"remote_pending_debt": "0"
},
"pending_transactions": {
"local": {},
"remote": {}
}
}
}
},
"active_currencies": {
"local": [
"ILS"
],
"remote": [
"ILS"
]
}
},
"pending_requests": [],
"pending_backwards_ops": [],
"pending_user_requests": []
}
}
}
},
"open_invoices": {},
"open_transactions": {},
"payments": {}
},
"index_client_config": {
"index_servers": [
{
"publicKey": "EXuvtumXU8gmLM40LQAYcAxnH5aFHeU_CSN_SH8Q4mI",
"address": "index2.offsetcredit.org:11385",
"name": "index2"
}
]
}
} |
The first thing that comes to mind is that a key-value store, something like mongo-db, can already be an improvement over re-writing a json-file. I think the complexity there is reduced in comparison with a relational database, but you still save re-writing everything each time. It's probably reasonable possible to do this and still use serde for encoding the content. Another thing which is worth considering in a storage solution is ease of migration. But I don't know what exactly to say about this here. I'll try to think about this some more later. |
Thanks! I hoped to avoid anything that requires a database that can not be stored plainly inside a file, to keep things simple. If I use mongo-db, will there be any complications when shipping it inside an android/ios app? |
We are currently using serialization to json file (using
serde
) and writing to disk using theatomicwrites
crate.Cons of the current design:
atomicwrites
crate.Required steps:
The text was updated successfully, but these errors were encountered: