hfc.util.keyvaluestore

Module Contents

Classes

KeyValueStore()

An key value store for blockchain application state persistence.

FileKeyValueStore(path)

A key value store implementation based file system.

Functions

_make_dir(path)

file_key_value_store(path)

Factory method for creating file key value store.

class hfc.util.keyvaluestore.KeyValueStore

Bases: object

An key value store for blockchain application state persistence.

abstract set_value(self, key, value)

Set a value with a specific key.

Parameters
  • key – key

  • value – value

abstract get_value(self, key)

Get a value with a specific key.

Parameters

key – key

Returns

value

abstract async_set_value(self, key, value, scheduler=None)

Set a value with a specific key.

Parameters
  • scheduler – scheduler

  • key – key

  • value – value

:return:a future object

abstract async_get_value(self, key, scheduler=None)

Get a value with a specific key.

Parameters
  • scheduler – scheduler

  • key – key

:return:a future object

class hfc.util.keyvaluestore.FileKeyValueStore(path)

Bases: hfc.util.keyvaluestore.KeyValueStore

A key value store implementation based file system.

set_value(self, key, value)

Set a value with a specific key.

Args:

key: key value: value

Returns: True when success Raises: File manipulate exceptions

get_value(self, key)

Get a value with a specific key.

Parameters

key – key

Returns

value

async_get_value(self, key, scheduler=None)

Get a value with a specific key.

Parameters
  • scheduler – scheduler

  • key – key

:return:a future object

async_set_value(self, key, value, scheduler=None)

Set a value with a specific key.

Parameters
  • scheduler – scheduler

  • key – key

  • value – value

:return:a future object

get_attrs(self)
__str__(self)

Return str(self).

hfc.util.keyvaluestore._make_dir(path)
hfc.util.keyvaluestore.file_key_value_store(path)

Factory method for creating file key value store.

Parameters

path – path

:return an instance of file key value store