Socket
Socket
Sign inDemoInstall

github.com/EXCCoin/exccd/database/v3

Package Overview
Dependencies
15
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    github.com/EXCCoin/exccd/database/v3

Package database provides a block and metadata storage database. This package provides a database layer to store and retrieve block data and arbitrary metadata in a simple and efficient manner. The default backend, ffldb, has a strong focus on speed, efficiency, and robustness. It makes use leveldb for the metadata, flat files for block storage, and strict checksums in key areas to ensure data integrity. A quick overview of the features database provides are as follows: The main entry point is the DB interface. It exposes functionality for transactional-based access and storage of metadata and block data. It is obtained via the Create and Open functions which take a database type string that identifies the specific database driver (backend) to use as well as arguments specific to the specified driver. The Namespace interface is an abstraction that provides facilities for obtaining transactions (the Tx interface) that are the basis of all database reads and writes. Unlike some database interfaces that support reading and writing without transactions, this interface requires transactions even when only reading or writing a single key. The Begin function provides an unmanaged transaction while the View and Update functions provide a managed transaction. These are described in more detail below. The Tx interface provides facilities for rolling back or committing changes that took place while the transaction was active. It also provides the root metadata bucket under which all keys, values, and nested buckets are stored. A transaction can either be read-only or read-write and managed or unmanaged. A managed transaction is one where the caller provides a function to execute within the context of the transaction and the commit or rollback is handled automatically depending on whether or not the provided function returns an error. Attempting to manually call Rollback or Commit on the managed transaction will result in a panic. An unmanaged transaction, on the other hand, requires the caller to manually call Commit or Rollback when they are finished with it. Leaving transactions open for long periods of time can have several adverse effects, so it is recommended that managed transactions are used instead. The Bucket interface provides the ability to manipulate key/value pairs and nested buckets as well as iterate through them. The Get, Put, and Delete functions work with key/value pairs, while the Bucket, CreateBucket, CreateBucketIfNotExists, and DeleteBucket functions work with buckets. The ForEach function allows the caller to provide a function to be called with each key/value pair and nested bucket in the current bucket. As discussed above, all of the functions which are used to manipulate key/value pairs and nested buckets exist on the Bucket interface. The root metadata bucket is the upper-most bucket in which data is stored and is created at the same time as the database. Use the Metadata function on the Tx interface to retrieve it. The CreateBucket and CreateBucketIfNotExists functions on the Bucket interface provide the ability to create an arbitrary number of nested buckets. It is a good idea to avoid a lot of buckets with little data in them as it could lead to poor page utilization depending on the specific driver in use. This example demonstrates creating a new database and using a managed read-write transaction to store and retrieve metadata. This example demonstrates creating a new database, using a managed read-write transaction to store a block, and using a managed read-only transaction to fetch the block.


Version published

Readme

Source

database

Build Status ISC License Doc

Package database provides a block and metadata storage database.

Please note that this package is intended to enable exccd to support different database backends and is not something that a client can directly access as only one entity can have the database open at a time (for most database backends), and that entity will be exccd.

When a client wants programmatic access to the data provided by exccd, they'll likely want to use the rpcclient package which makes use of the JSON-RPC API.

However, this package could be extremely useful for any applications requiring Exchangecoin block storage capabilities.

The default backend, ffldb, has a strong focus on speed, efficiency, and robustness. It makes use of leveldb for the metadata, flat files for block storage, and strict checksums in key areas to ensure data integrity.

Feature Overview

  • Key/value metadata store
  • Exchangecoin block storage
  • Efficient retrieval of block headers and regions (transactions, scripts, etc)
  • Read-only and read-write transactions with both manual and managed modes
  • Nested buckets
  • Iteration support including cursors with seek capability
  • Supports registration of backend databases
  • Comprehensive test coverage

Installation

$ go get github.com/EXCCoin/exccd/database2

Examples

  • Basic Usage Example Demonstrates creating a new database and using a managed read-write transaction to store and retrieve metadata.

  • Block Storage and Retrieval Example Demonstrates creating a new database, using a managed read-write transaction to store a block, and then using a managed read-only transaction to fetch the block.

License

Package database is licensed under the copyfree ISC License.

FAQs

Last updated on 14 Nov 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc