Skip to main content

We're Done

We did it! The smart function, 2VotesMajority, is all we need to ensure that _user/username cannot be changed without at least 2 votes, and a majority of votes being yes votes.

For now, only softCell has voted to change their name to hardCell. If you were following along with this lesson in your own database, you would find that the following transaction (signed with softCell's private key) would fail:

[
{
"_id": ["_user/username", "softCell"],
"username": "softCell"
}
]

If wanted this transaction to pass, we could add two more votes, each signed with the relevant private key.

[
{
"_id": ["vote/name", "softCellNameVote"],
"yesVotes": [["_auth/id", "TfFoQ4yB3vFn3th7Vce36Cb45fDau255GdH"]]
}
]
[
{
"_id": ["vote/name", "softCellNameVote"],
"yesVotes": [["_auth/id", "TfBvBxdxcXNrDQY8aNcYmoUuA2TC1CTiWAK"]]
}
]

If you want to play around with this database, you can add specs to other predicates, and vote for other changes. Note, that we did not allow new auth records to be added (otherwise users could artificially inflate vote counts). In a real application, you'd want to create a secure mechanism to create additional auth record.