TBD54566975 / dwn-sdk-js

Decentralized Web Node (DWN) Reference implementation

Home Page:https://identity.foundation/decentralized-web-node/spec/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Investigate and fix unwanted storage of junk/invalid data in `DataStoreLevel` implementation

thehenrytsai opened this issue · comments

There appears a bug in DataStoreLevel.put() implementation where if there exists a piece of data with dataCid X in the store, and another put()is called with the same tenantId and dataCid X but incorrect data stream, this incorrect data would be stored indefinitely as chunks.

A potential way to fix this is to:

  1. push the dataCid check currently done by the caller of put() into put() itself.
  2. attempt to see if an existing data with dataCid X is in the store, if in this store, then read the data stream into a temporary location (to be deleted later). If not in the store, then proceed to happy/common path (also require code tweaks in this path.
  3. validate the dataCid of data in temporary location and react accordingly.