trueblocks-core
trueblocks-core copied to clipboard
chifra cmd - global --raw option should disable cache reading
If we decache an item, then ask for it's --raw version, we get results. If we later --cache that same item and then subsequently look at its --raw version, we get null. This is because we don't store --raw data in the cache (should we? see below). When read from the cache, we only consider if the item is in the cache, not if the cache is turned on, thus null raw data.
This reproduces the issue:
chifra traces 1001001.3 --decache
chifra traces 1001001.3 --raw # see results
chifra traces 1001001.3 --cache
chifra traces 1001001.3 --raw # no results
This issue applies to anything we cache (transactions, logs, receipts, etc.)
Alternatives
- We could store raw data but that would nearly double the size of the cache. This is a no-go.
- We could change the cache to store only the raw data since the non-raw data can be re-created and the raw data (i.e., data from the node) is what we want to avoid having to query twice), but this adds a migration and more complicate cache reading code which is automated.
- The solution we should opt in for is to not read the cache if the user specified
--raw. The trouble with this is we do not check the on/off status of the cache when reading. We read the cache if the cache file is present. - A fourth method would be to "re-create" raw from the cache file, but this violates the idea of
rawwhich is to send exactly what's gotten from the node.