Closed gatoWololo closed 1 year ago
One thought: if we are planning to split out Storage
into a trait in the future, we might want to hide T::Value
from the caller (since the implementer of the Storage
trait won't know the internal details, right?). So should we still use Vec<u8>
as the underlying storage in the HashMap
instead of Box<dyn Any>
?
I was thinking that the design and implementation here would only be for local storage. As the main storage will likely have to look different and have different requirements:
TypeId
we use to differentiate different stored values have limitations: "While TypeId implements Hash, PartialOrd, and Ord, it is worth noting that the hashes and ordering will vary between Rust releases. Beware of relying on them inside of your code!" So we should not use those for persistent storage, which may need to live through releases and recompilations of the servers.I was thinking that the design and implementation here would only be for local storage.
Ah, that makes sense!
Our LocalStorage has a few shortcomings we would like to fix:
Vec<u8>
.(ParticipantId, Identifier)
to store values. (Currently the key/index to access stored values is also aVec<u8>
this makes it hard to e.g iterate over entries of a specificIdentifier
).There is a couple of problems with this approach:
(ParticipantId, Identifier)
isn't enough for a sub-participant to uniquely specify different stored values.Instead, here is a sketch implementation for a new storage type:
Anyways. I got carried away having fun with this.
Closing Criteria
local_storage.rs
file which includes theGenericStorage
type (probably renamed intoLocalStorage
) as well as theTypeTag
trait.LocalStorage
: #183, #184, #185.