This commit updates the tstore backend key-value store to allow for
overwrites when using the Put() method. New entries are inserted.
Existing entries are updated.
After reviewing the tstore architecture, I realized that the duplicate
entry error that was added in 950620c was the wrong way to handle
duplicate key errors.
tstore saves data using a 2-step process. Step 1, save the data to the
key-value store. Step 2, append the hash of the data onto the trillian
tree. If step 2 fails, the key-value store entries are not unwound, they
are simply left in the key-value store. It was originally setup like
this to keep the required database primitives as simple as possible to
allow for flexibility in the database choice. The thought was that, at
some point in the future, it might be possible to drop in a
decentralized storage technology as the backing key-value store.
In the above scenerio where step 2 fails, any attempts to resubmit the
data would result in a duplicate key error if the data was unchanged.
This is why the Put() method is being updated to allow for overwrites.
This commit updates the tstore backend key-value store to allow for overwrites when using the Put() method. New entries are inserted. Existing entries are updated.
After reviewing the tstore architecture, I realized that the duplicate entry error that was added in 950620c was the wrong way to handle duplicate key errors.
tstore saves data using a 2-step process. Step 1, save the data to the key-value store. Step 2, append the hash of the data onto the trillian tree. If step 2 fails, the key-value store entries are not unwound, they are simply left in the key-value store. It was originally setup like this to keep the required database primitives as simple as possible to allow for flexibility in the database choice. The thought was that, at some point in the future, it might be possible to drop in a decentralized storage technology as the backing key-value store.
In the above scenerio where step 2 fails, any attempts to resubmit the data would result in a duplicate key error if the data was unchanged. This is why the Put() method is being updated to allow for overwrites.