Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BsonFileBlockHeightSwCache<V>

An implementation of BlockHeightSwCache that stores its data in BSON files. Data is flushed to disk every 10 new cache entries.

Main use-case is the per block height state cache for contracts.

A separate file is created for each block height - otherwise it was common to hit 16 megabytes file size limit for bson files.

At time of writing, completely cached state for all contracts, at all block heights, was taking ~2.5GB of disk space :-).

The files are organised in the following structure: --/basePath --/txId_1 --1.cache.bson --2.cache.bson ... --748832.cache.bson --/txId_2 --1.cache.bson --323332.cache.bson ...etc.

Note: this is not performance-optimized for reading LARGE amount of contracts ;-)

Type parameters

  • V = any

Hierarchy

  • BsonFileBlockHeightSwCache

Implements

Index

Constructors

constructor

Properties

Private Readonly basePath

basePath: any

Private putCounter

putCounter: number = 0

Private saving

saving: boolean = false

Private Readonly storage

storage: {}

Type declaration

  • [key: string]: {}
    • [blockHeight: string]: V

Private updatedStorage

updatedStorage: {} = {}

Type declaration

  • [key: string]: {}
    • [blockHeight: string]: V

Methods

contains

  • contains(key: string): Promise<boolean>

get

getLast

getLessOrEqual

put

Private saveCache

  • saveCache(): void

Generated using TypeDoc