dfuse-eosio
dfuse-eosio copied to clipboard
accounthist: write keys in order
the KVStore::FlushPuts() needs to write each account's new keys in order, otherwise, upon restart, we will take the highest key, and continue from there.. but there are risks we have not written everything before that highest one.
By ditching the RWCache as a KVStore abstraction, and making it into a simple Buffered keys accumulator, instead of having keys there, have something like:
type Accumulator struct {
accountRows map[uint64]*linkedListOfKV, with each element being a tuple: key, serialized ActionRow
deletes *linkedListOfKeys
// use the ws.lastShardCheckpoint, serialize and write..
// no need to do it each time, as we know its overwritten
}
and when we flush, we'd go through the keys of accounts, do a whole bunch of Put(), and then FlushPuts() on the underlying KVStore.. we'll be sure they are in order, then do the deletes, and finish by writing the CheckpointRow for the shard at the end, sealing the progress.