disk

package
v0.0.0-...-565936f Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package disk implements the ability to read and write blocks to disk writing each block to a separate block numbered file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Disk

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

Disk represents the serialization implementation for reading and storing blocks in their own separate files on disk. This implements the database.Storage interface.

func New

func New(dbPath string) (*Disk, error)

New constructs an Disk value for use.

func (*Disk) Close

func (d *Disk) Close() error

Close in this implementation has nothing to do since a new file is written to disk for each now block and then immediately closed.

func (*Disk) ForEach

func (d *Disk) ForEach() database.Iterator

ForEach returns an iterator to walk through all the blocks starting with block number 1.

func (*Disk) GetBlock

func (d *Disk) GetBlock(num uint64) (database.BlockData, error)

GetBlock searches the blockchain on disk to locate and return the contents of the specified block by number.

func (*Disk) Reset

func (d *Disk) Reset() error

Reset will clear out the blockchain on disk.

func (*Disk) Write

func (d *Disk) Write(blockData database.BlockData) error

Write takes the specified database blocks and stores it on disk in a file labeled with the block number.

Jump to

Keyboard shortcuts

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