ledger

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

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

Go to latest
Published: Mar 28, 2026 License: BSD-3-Clause Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LutherEventKey         = "luther"
	LutherEventName        = "txEventName"
	LutherEventRequestID   = "txRequestID"
	LutherEventTxTimestamp = "txTimestamp"
)

Variables

This section is empty.

Functions

func GetCSVBlockHeader

func GetCSVBlockHeader() []string

func GetCSVLedgerViewHeader

func GetCSVLedgerViewHeader() []string

GetCSVLedgerViewHeader returns the CSV header for ledger view data

func GetLutherRecordHeader

func GetLutherRecordHeader() []string

func NewBlockStore

func NewBlockStore(path string, orderer bool) (*blockStore, error)

func RangeBlocks

func RangeBlocks(ledgerDir string, orderer bool, channel string, start uint64, end uint64) (*simpleBlockIterator, error)

Types

type Block

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

Block is a container for the transaction information.

func NewBlock

func NewBlock(blk *cb.Block) (*Block, error)

func (*Block) GetBlockNum

func (b *Block) GetBlockNum() uint64

GetBlockNum returns the block number.

func (*Block) GetHash

func (b *Block) GetHash() string

GetHash returns block hash.

func (*Block) GetTransactions

func (b *Block) GetTransactions() []*Transaction

GetTransactions returns the transactions in the block.

func (*Block) GetValidation

func (s *Block) GetValidation(txNum int) *TxValidation

func (*Block) ToLedgerView

func (b *Block) ToLedgerView() *LedgerView

ToLedgerView converts a Block to a LedgerView

func (*Block) Write

func (b *Block) Write(w io.Writer)

func (*Block) WriteCSV

func (b *Block) WriteCSV(w *csv.Writer)

func (*Block) WriteTx

func (b *Block) WriteTx(i int, w io.Writer)

type BlockIterator

type BlockIterator interface {
	Next() (CommonBlock, error)
	Close()
}

type CommonBlock

type CommonBlock struct {
	cb.Block
}

func (*CommonBlock) Write

func (s *CommonBlock) Write(w io.Writer)

func (*CommonBlock) WriteCSV

func (s *CommonBlock) WriteCSV(w *csv.Writer)

type Event

type Event struct {
	*fabricpeer.ChaincodeEvent
}

func (*Event) GetChaincodeId

func (s *Event) GetChaincodeId() string

func (*Event) GetLutherRecord

func (s *Event) GetLutherRecord() []string

func (*Event) GetPayload

func (s *Event) GetPayload() []byte

func (*Event) IsLutherEvent

func (s *Event) IsLutherEvent() bool

func (*Event) String

func (s *Event) String() string

type KeyRecord

type KeyRecord struct {
	Type        string // "state" or "private"
	Namespace   string // namespace for state, collection for private
	Key         string
	Value       []byte
	ValueSize   int
	Version     *Version // optional, for read sets
	IsRead      bool     // true if this is from a read set
	IsWrite     bool     // true if this is from a write set or current state
	Transaction string   // optional transaction ID
	BlockNum    uint64   // optional block number
}

KeyRecord represents a single key-value record in the ledger

type LedgerStatistics

type LedgerStatistics struct {
	TotalKeys        int
	TotalStateKeys   int
	TotalPrivateKeys int
	TotalSize        int64
	TotalStateSize   int64
	TotalPrivateSize int64
	Namespaces       map[string]int
	Collections      map[string]int
	BlockCount       uint64
	TransactionCount int
}

LedgerStatistics contains aggregated statistics about the ledger

type LedgerView

type LedgerView struct {
	Keys       []*KeyRecord
	Statistics *LedgerStatistics
}

LedgerView represents a unified view of ledger data that can be populated from either Fabric blocks or Badger snapshots

func NewLedgerView

func NewLedgerView() *LedgerView

NewLedgerView creates a new empty ledger view

func (*LedgerView) AddKey

func (lv *LedgerView) AddKey(key *KeyRecord)

AddKey adds a key record to the view

func (*LedgerView) Write

func (lv *LedgerView) Write(w io.Writer)

Write writes a formatted summary of the ledger view

func (*LedgerView) WriteCSV

func (lv *LedgerView) WriteCSV(w *csv.Writer)

WriteCSV writes ledger view data rows in CSV format. The caller is responsible for writing the header row (see GetCSVLedgerViewHeader).

type NSRWSet

type NSRWSet struct {
	RWSet     *RWSet
	Namespace string
}

func (*NSRWSet) GetNamespace

func (s *NSRWSet) GetNamespace() string

func (*NSRWSet) GetReadWriteSet

func (s *NSRWSet) GetReadWriteSet() *RWSet

type PrivateKey

type PrivateKey struct {
	Collection string
	Key        string
	Value      []byte
}

PrivateKey represents a private data key in the snapshot

type RSetRecord

type RSetRecord struct {
	Version *Version
	Key     string
}

func (*RSetRecord) GetKey

func (s *RSetRecord) GetKey() string

func (*RSetRecord) GetVersion

func (s *RSetRecord) GetVersion() *Version

type RWSet

type RWSet struct {
	ReadSet  []*RSetRecord
	WriteSet []*WSetRecord
}

func (*RWSet) GetReadSet

func (s *RWSet) GetReadSet() []*RSetRecord

func (*RWSet) GetWriteSet

func (s *RWSet) GetWriteSet() []*WSetRecord

type SnapshotState

type SnapshotState struct {
	StateKeys   []*StateKey
	PrivateKeys []*PrivateKey
	// contains filtered or unexported fields
}

SnapshotState represents the state of a Luther snapshot ledger

func LoadSnapshot

func LoadSnapshot(r io.Reader) (*SnapshotState, error)

LoadSnapshot loads a Luther snapshot from an io.Reader

func LoadSnapshotFromFile

func LoadSnapshotFromFile(filePath string) (*SnapshotState, error)

LoadSnapshotFromFile loads a snapshot from a file path

func (*SnapshotState) GetStats

func (s *SnapshotState) GetStats() *SnapshotStats

GetStats returns statistics about the snapshot

func (*SnapshotState) ToLedgerView

func (s *SnapshotState) ToLedgerView() *LedgerView

ToLedgerView converts a SnapshotState to a LedgerView

func (*SnapshotState) Write

func (s *SnapshotState) Write(w io.Writer)

Write writes a formatted summary of the snapshot to the writer

func (*SnapshotState) WriteCSV

func (s *SnapshotState) WriteCSV(w *csv.Writer)

WriteCSV writes snapshot data in CSV format

type SnapshotStats

type SnapshotStats struct {
	TotalStateKeys   int
	TotalPrivateKeys int
	TotalStateSize   int64
	TotalPrivateSize int64
	Namespaces       map[string]int
	Collections      map[string]int
}

SnapshotStats contains statistics about the snapshot

type StateKey

type StateKey struct {
	Namespace string
	Key       string
	Value     []byte
}

StateKey represents a state key in the snapshot

type Transaction

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

Transaction is a container for the transaction information exported by QueryBlock.

func NewTransaction

func NewTransaction(envelopeBytes []byte) (*Transaction, error)

NewTransaction creates an immutable transaction object.

func (*Transaction) GetDetails

func (t *Transaction) GetDetails() *TransactionDetails

func (*Transaction) GetID

func (t *Transaction) GetID() TransactionID

ID is the transaction ID.

func (*Transaction) GetNumber

func (t *Transaction) GetNumber() int

func (*Transaction) GetSize

func (t *Transaction) GetSize() int

type TransactionDetails

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

func NewTransactionDetails

func NewTransactionDetails(txBytes []byte) (*TransactionDetails, error)

func (*TransactionDetails) GetEvent

func (s *TransactionDetails) GetEvent() *Event

func (*TransactionDetails) GetNamespaceReadWriteSet

func (s *TransactionDetails) GetNamespaceReadWriteSet() []*NSRWSet

func (*TransactionDetails) GetReadSetSize

func (s *TransactionDetails) GetReadSetSize() int64

func (*TransactionDetails) GetWriteSetSize

func (s *TransactionDetails) GetWriteSetSize() int64

type TransactionID

type TransactionID string

type TxValidation

type TxValidation int32

func (*TxValidation) GetReason

func (s *TxValidation) GetReason() string

type Version

type Version struct {
	BlockNum uint64
	TxNum    uint64
}

func (*Version) String

func (s *Version) String() string

type WSetRecord

type WSetRecord struct {
	Key string
	Val []byte
}

func (*WSetRecord) GetKey

func (s *WSetRecord) GetKey() string

func (*WSetRecord) GetVal

func (s *WSetRecord) GetVal() []byte

Jump to

Keyboard shortcuts

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