lambda_ethereum_consensus icon indicating copy to clipboard operation
lambda_ethereum_consensus copied to clipboard

refactor: delete duplicated logic and wrap DBLevel calls

Open leobz opened this issue 1 year ago • 3 comments

Motivation

Wrap Exleveldb and :eleveldb calls into Db module to centralize logic, and refactor Db module to avoid duplicated code and decrease effort by adding leveldb functions.

Description

  • Refactor Db module, extracting repeated logic to perform/2 function

  • Replace Exleveldb and :eleveldb calls by adding the functions to Db module

  • TODO: Add all the features of Exleveldb with tests

  • TODO: Implement macros if necessary

Closes #1191

leobz avatar Sep 03 '24 22:09 leobz

Arkenan Sorry for the delay. There is no problem! Only to confirm, is it okay to quit the Exleveldb calls iterator_close and iterator_move from BlobDB and KVSchema and use them wrapped in the DB module?

This should be the refactor in that case -> https://github.com/lambdaclass/lambda_ethereum_consensus/pull/1285/files

leobz avatar Sep 10 '24 15:09 leobz

Hi @leobz thanks for the update! I really like the code. Marked it ready for review and run CI. It seems to be doing pretty well, but dialyzer (type analyzer) failed. You may debug that locally by running make dialyzer and seeing what's wrong. At a first glance, it seems that the typespec for the Db.iterator_move function is too restrictive or doesn't match the contract.

Arkenan avatar Sep 13 '24 17:09 Arkenan

Thank you @Arkenan! Sorry for the delay, I wasn't available these weeks, but I'm going to fix it :raised_hands:

leobz avatar Sep 24 '24 22:09 leobz