blockchaindb

package
v1.0.0-release Latest Latest
Warning

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

Go to latest
Published: May 19, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddBlockToBlockchain

func AddBlockToBlockchain(log *ipfsLog.ZapEventLogger, b *block.Block, db *BlockchainDB) bool

AddBlockToBlockchain adds a block to the blockchain db.

Types

type BlockchainDB

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

BlockchainDB wraps a Pebble database instance to store blockchain data.

func NewBlockchainDB

func NewBlockchainDB(log *ipfsLog.ZapEventLogger, dbPath string) (*BlockchainDB, error)

BlockchainDB wraps a Pebble database instance to store blockchain data.

func (*BlockchainDB) Close

func (pdb *BlockchainDB) Close(log *ipfsLog.ZapEventLogger) error

Close closes the database connection.

func (*BlockchainDB) GetBlock

func (pdb *BlockchainDB) GetBlock(log *ipfsLog.ZapEventLogger, key []byte) (*block.Block, error)

GetBlock retrieves a block from the database using its key.

func (*BlockchainDB) GetLastBlock

func (pdb *BlockchainDB) GetLastBlock(log *ipfsLog.ZapEventLogger) *block.Block

GetLastBlock retrieves the most recently added block from the database.

func (*BlockchainDB) SaveBlock

func (pdb *BlockchainDB) SaveBlock(log *ipfsLog.ZapEventLogger, key []byte, b *block.Block) error

SaveBlock serializes and stores a given block in the database.

func (*BlockchainDB) VerifyIntegrity

func (pdb *BlockchainDB) VerifyIntegrity(log *ipfsLog.ZapEventLogger) bool

VerifyIntegrity verifies the integrity of the blockchain stored in the BlockchainDB based on the last block.

type BlockchainStorage

type BlockchainStorage interface {
	SaveBlock(log *ipfsLog.ZapEventLogger, key []byte, b *block.Block) error
	GetBlock(log *ipfsLog.ZapEventLogger, key []byte) (*block.Block, error)
	VerifyIntegrity(log *ipfsLog.ZapEventLogger) (bool, error)
	GetLastBlock(log *ipfsLog.ZapEventLogger) *block.Block
	Close(log *ipfsLog.ZapEventLogger) error
}

BlockchainStorage defines an interface for interacting with the blockchain storage.

Jump to

Keyboard shortcuts

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