It seems we forget to cache non-existent key in data cache. If a non-existent key is searched multiple times in a snapshot cache during a block period, currently every time it would be searched in levelDB, which can be very time consuming.
If we have a set in data cache which includes non-existent keys which have been confirmed in current snapshot, above occasions would be avoided.
I.e. each time handling a transfer during block persisting, we will check the payable status of the transfer destination:
|
ContractState contract_to = engine.Snapshot.Contracts.TryGet(to); |
Address contract is not stored in levelDB, and non-existent record is currently not recorded. So every time the tryget will lead to a levelDB search, even if the searched scripthash has been searched before within current snapshot.
It seems we forget to cache non-existent key in data cache. If a non-existent key is searched multiple times in a snapshot cache during a block period, currently every time it would be searched in levelDB, which can be very time consuming.
If we have a set in data cache which includes non-existent keys which have been confirmed in current snapshot, above occasions would be avoided.
I.e. each time handling a transfer during block persisting, we will check the payable status of the transfer destination:
neo/src/neo/SmartContract/Native/Tokens/Nep5Token.cs
Line 165 in a5cf5b2
Address contract is not stored in levelDB, and non-existent record is currently not recorded. So every time the tryget will lead to a levelDB search, even if the searched scripthash has been searched before within current snapshot.