Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Update lisk-chain data_access layer #5257

Closed
ManuGowda opened this issue May 2, 2020 · 0 comments · Fixed by #5314
Closed

Update lisk-chain data_access layer #5257

ManuGowda opened this issue May 2, 2020 · 0 comments · Fixed by #5314

Comments

@ManuGowda
Copy link
Contributor

ManuGowda commented May 2, 2020

Description

With the introduction of an embedded database system, the data access layer interface needs to be updated to support queries using the embedded database system's APIs.

Acceptance Criteria

  • Update storage related types in lisk-chain
  • Update data_access->storage to get EmbeddedDB instance
  • Update data_access->storage public interfaces to use EmbeddedDB interface
  • Update unit tests according to EmbeddedDB interface
  • Add integration tests for data_access layer
  • Use json encoder
  • Remove prepare and validate to simplify transaction interface

Additional Information

  • Database keys should be as below, and height key should be big endian encoded number
blocks:height:xxxx => id
blocks:id:xxxx => BlockHeader
transactions:id:xxxx => Transaction
transactions:blockID:xxxxx => TxID[]
accounts:address:xxxx => Account
tempBlocks:height:xxx => FullBlock
  • Some of the interface supported by EmbeddedDB
// put
await db.get('blocks:height:00000000000000001', 'test')

// get
await db.get('blocks:height:0000000000000001')

// del
await db.del('blocks:height:00000000000000001')

// batch
await db.batch()
  .del('blocks:height:0000000000000001')
  .put('blocks:height:0000000000000010', 'test1')
  .put('blocks:height:0000000000000010', 'test2')
  .put('blocks:height:0000000000000010', 'test3')
  .write()

// events
db.on(<operation>, (k, v) => {})

// put
await db.get('blocks:height:00000000000000001', 'test1')

// get
await db.get('blocks:height:0000000000000001')

// del
await db.del('blocks:height:00000000000000001')

// batch
await db.batch()
  .del('blocks:height:0000000000000001')
  .put('blocks:height:0000000000000010', 'test2')
  .put('blocks:height:0000000000000010', 'test3')
  .put('blocks:height:0000000000000010', 'test4')
  .write()

// events
db.on(<operation>, (k, v) => {})

Related issues: #5238

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants