bolt

package
v0.0.0-...-8b83558 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package bolt provides a bbolt-based implementation of the blockchain Storage interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(dbPath string) (database.Storage, error)

New opens (or creates) a bbolt database at the specified path and returns a Bolt storage device.

Types

type Bolt

type Bolt struct {
	// contains filtered or unexported fields
}

Bolt implements the Storage interface using a bbolt database.

func (*Bolt) Close

func (bs *Bolt) Close() error

Close closes the underlying bbolt database.

func (*Bolt) ForEach

func (bs *Bolt) ForEach() database.Iterator

ForEach returns an iterator that traverses blocks in ascending numerical order. Each `Next()` call will open its own short-lived read transaction, fetch exactly one block, close that transaction, and return the block. If the block does not exist, `Next()` sets `done = true`.

func (*Bolt) GetBlock

func (bs *Bolt) GetBlock(num uint64) (database.BlockData, error)

GetBlock retrieves a block from the database by block number.

func (*Bolt) Reset

func (bs *Bolt) Reset() error

Reset deletes all blockchain data by deleting and recreating the "blocks" bucket.

func (*Bolt) WriteBlock

func (bs *Bolt) WriteBlock(blockData database.BlockData) error

WriteBlock writes a new block to the database. The block is stored as a key/value pair with the block number as the key.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL