ledgermgmt

package
v0.0.0-...-579b097 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrLedgerAlreadyOpened = errors.New("ledger already opened")

ErrLedgerAlreadyOpened is thrown by a CreateLedger call if a ledger with the given id is already opened

View Source
var ErrLedgerMgmtNotInitialized = errors.New("ledger mgmt should be initialized before using")

ErrLedgerMgmtNotInitialized is thrown when ledger mgmt is used before initializing this

Functions

This section is empty.

Types

type Initializer

type Initializer struct {
	CustomTxProcessors              map[common.HeaderType]ledger.CustomTxProcessor
	StateListeners                  []ledger.StateListener
	DeployedChaincodeInfoProvider   ledger.DeployedChaincodeInfoProvider
	MembershipInfoProvider          ledger.MembershipInfoProvider
	ChaincodeLifecycleEventProvider ledger.ChaincodeLifecycleEventProvider
	MetricsProvider                 metrics.Provider
	HealthCheckRegistry             ledger.HealthCheckRegistry
	Config                          *ledger.Config
	HashProvider                    ledger.HashProvider
	EbMetadataProvider              MetadataProvider
}

Initializer encapsulates all the external dependencies for the ledger module

type LedgerMgr

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

LedgerMgr manages ledgers for all channels

func NewLedgerMgr

func NewLedgerMgr(initializer *Initializer) *LedgerMgr

NewLedgerMgr creates a new LedgerMgr

func (*LedgerMgr) Close

func (m *LedgerMgr) Close()

Close closes all the opened ledgers and any resources held for ledger management

func (*LedgerMgr) CreateLedger

func (m *LedgerMgr) CreateLedger(id string, genesisBlock *common.Block) (ledger.PeerLedger, error)

CreateLedger creates a new ledger with the given genesis block. This function guarantees that the creation of ledger and committing the genesis block would an atomic action. The channel id retrieved from the genesis block is treated as a ledger id. It returns an error if another ledger is being created from a snapshot.

func (*LedgerMgr) CreateLedgerFromSnapshot

func (m *LedgerMgr) CreateLedgerFromSnapshot(snapshotDir string, channelCallback func(ledger.PeerLedger, string)) error

CreateLedgerFromSnapshot creates a new ledger with the given snapshot and executes the callback function after the ledger is created. This function launches to goroutine to create the ledger and call the callback func. All ledger dbs would be created in an atomic action. The channel id retrieved from the snapshot metadata is treated as a ledger id. It returns an error if another ledger is being created from a snapshot.

func (*LedgerMgr) GetLedgerIDs

func (m *LedgerMgr) GetLedgerIDs() ([]string, error)

GetLedgerIDs returns the ids of the ledgers created

func (*LedgerMgr) JoinBySnapshotStatus

func (m *LedgerMgr) JoinBySnapshotStatus() *pb.JoinBySnapshotStatus

JoinBySnapshotStatus returns the status of joinbysnapshot which includes ledger creation and channel callback.

func (*LedgerMgr) OpenLedger

func (m *LedgerMgr) OpenLedger(id string) (ledger.PeerLedger, error)

OpenLedger returns a ledger for the given id

type MetadataProvider

type MetadataProvider interface {
	PackageMetadata(ccid string) ([]byte, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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