Skip to content
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

exp/recoverysigner: improve PUT /accounts/{address} with a delta set #2500

Closed
howardtw opened this issue Apr 21, 2020 · 1 comment
Closed

Comments

@howardtw
Copy link
Contributor

Why

Right now we are replacing the existing identifies and auth methods of an account with the incoming identities by deleting all identities of the account and re-insert the new identities, which can be optimized.

For example,
If the original identities are the following

"identities": [
		{
			"role": "owner",
			"auth_methods": [
				{ "type": "stellar_address", "value": "GBF3XFXGBGNQDN3HOSZ7NVRF6TJ2JOD5U6ELIWJOOEI6T5WKMQT2YSXQ" },
				{ "type": "phone_number", "value": "+10000000000" },
			]
		}
	]

updating it to become

"identities": [
		{
			"role": "owner",
			"auth_methods": [
				{ "type": "stellar_address", "value": "GBF3XFXGBGNQDN3HOSZ7NVRF6TJ2JOD5U6ELIWJOOEI6T5WKMQT2YSXQ" },
				{ "type": "phone_number", "value": "+10000000000" },
				{ "type": "email", "value": "[email protected]" }
			]
		}
	]

should only involve one insertion to the auth_methods table (email, user1@example) as opposed to remove the existing 1 identity and 2 auth methods and insert 1 identity and 3 auth methods.

However given that the expected use cases currently only involves a small number of identities and auth methods, replacing one set with another isn't that costly.

Note that we can't really use UPDATE statement because there could be more than one rows with the same auth_method_type, account_id, identity_id. This means that changing an auth value requires a DELETE statement and an INSERT statement.

Constructing a delta set for this operation can only benefit some of the cases and is not straightforward to get right. Thus we are deferring this optimization.

@mollykarcher
Copy link
Contributor

Closing all recoverysigner issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants