blockhelper

package
v2.3.7 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package blockhelper package

Index

Constants

View Source
const (
	BlockIndexKeyPrefix     = "ib"
	BlockMetaIndexKeyPrefix = "im"
)

nolint

View Source
const (
	BlockNumIdxKeyPrefix  = 'n'
	BlockHashIdxKeyPrefix = 'h'
	TxIDIdxKeyPrefix      = 't'
	//TxConfirmedTimeKeyPrefix = 'c'
	BlockTxIDIdxKeyPrefix = 'b'
	LastBlockNumKeyStr    = "lastBlockNumKey"
	LastConfigBlockNumKey = "lastConfigBlockNumKey"
	ArchivedPivotKey      = "archivedPivotKey"
)

nolint

Variables

View Source
var DbType_Mysql = "mysql"

DbType_Mysql nolint

Functions

func BuildKVBatch

func BuildKVBatch(isBFDB bool, batch *types.UpdateBatch, blockInfo *serialization.BlockWithSerializedInfo,
	dbType string, logger protocol.Logger)

BuildKVBatch add next time @Description: @param batch @param blockInfo @param dbType @param logger @return *types.UpdateBatch

func BuildKVBatchForBFDB

func BuildKVBatchForBFDB(batch *types.UpdateBatch, block *commonPb.Block,
	dbType string, logger protocol.Logger) *types.UpdateBatch

BuildKVBatchForBFDB add next time @Description: @param batch @param blockInfo @param dbType @param logger @return *types.UpdateBatch

func BuildKVBatchForRawDB

func BuildKVBatchForRawDB(batch *types.UpdateBatch, block *commonPb.Block,
	dbType string, logger protocol.Logger) *types.UpdateBatch

BuildKVBatchForRawDB add next time @Description: @param batch @param blockInfo @param dbType @param logger @return *types.UpdateBatch

func ConstructBlockHashKey

func ConstructBlockHashKey(dbType string, blockHash []byte) []byte

ConstructBlockHashKey construct block hash key format: h{blockHash}

@Description:
@param dbType
@param blockHash
@return []byte

func ConstructBlockIndexKey

func ConstructBlockIndexKey(dbType string, blockNum uint64) []byte

ConstructBlockIndexKey build block index key format: ib{blockNum}

@Description:
@param dbType
@param blockNum
@return []byte

func ConstructBlockMetaIndexKey

func ConstructBlockMetaIndexKey(dbType string, blockNum uint64) []byte

ConstructBlockMetaIndexKey build block meta index key

@Description:
@param dbType
@param blockNum
@return []byte

func ConstructBlockNumKey

func ConstructBlockNumKey(dbType string, blockNum uint64) []byte

ConstructBlockNumKey construct blockNum key format : n{blockNum}

@Description:
@param dbType
@param blockNum
@return []byte

func ConstructBlockTxIDKey

func ConstructBlockTxIDKey(txID string) []byte

ConstructBlockTxIDKey construct block tx id key format : b{txID}

@Description:
@param txID
@return []byte

func ConstructFBTxIDBlockInfo

func ConstructFBTxIDBlockInfo(height uint64, blockHash []byte, txIndex uint32, timestamp int64,
	blockFileIndex, txFileIndex *storePb.StoreInfo) []byte

ConstructFBTxIDBlockInfo marshal TransactionStoreInfo

@Description:
@param height
@param blockHash
@param txIndex
@param timestamp
@param blockFileIndex
@param txFileIndex
@return []byte

func ConstructTxIDBlockInfo

func ConstructTxIDBlockInfo(height uint64, blockHash []byte, txIndex uint32, timestamp int64) []byte

ConstructTxIDBlockInfo marshal TransactionStoreInfo

@Description:
@param height
@param blockHash
@param txIndex
@param timestamp
@return []byte

func ConstructTxIDKey

func ConstructTxIDKey(txId string) []byte

ConstructTxIDKey construct tx id key format : t{txId}

@Description:
@param txId
@return []byte

func DecodeBlockNum

func DecodeBlockNum(blockNumBytes []byte) uint64

DecodeBlockNum varint decode

@Description:
@param blockNumBytes
@return uint64

func DecodeBlockNumKey

func DecodeBlockNumKey(dbType string, blkNumBytes []byte) uint64

DecodeBlockNumKey decode

@Description:
@param dbType
@param blkNumBytes
@return uint64

func EncodeBlockNum

func EncodeBlockNum(blockNum uint64) []byte

EncodeBlockNum varint encode blockNum

@Description:
@param blockNum
@return []byte

func GetBlockByHeightKey

func GetBlockByHeightKey(dbHandle protocol.DBHandle, cacheSC *cache.StoreCacheMgr,
	heightKey []byte, includeTxs bool, logger protocol.Logger,
	handleTx func(txId string, vBytes []byte, err error) (*commonPb.Transaction, error)) (*commonPb.Block, error)

GetBlockByHeightKey 根据区块高度Key获得区块信息和其中的交易信息

@Description:
@receiver b
@param heightKey
@param includeTxs
@return *commonPb.Block
@return error

func GetFromCacheFirst

func GetFromCacheFirst(key []byte, dbHandle protocol.DBHandle, cacheSC *cache.StoreCacheMgr,
	logger protocol.Logger) ([]byte, error)

GetFromCacheFirst first from cache;if not found,from db

@Description:
@receiver b
@param key
@return []byte
@return error

func HandleFDKVRWSet

func HandleFDKVRWSet(vBytes []byte, err error) (*commonPb.TxRWSet, error)

HandleFDKVRWSet retrieves a transaction rwSet by txId in file block archived config block's tx, or returns nil if none exists. this rwSet is moved to kvDB while archive before

@Description:
@receiver b
@param txId
@return *commonPb.Transaction
@return error

func HandleFDKVTx

func HandleFDKVTx(_ string, vBytes []byte, err error) (*commonPb.Transaction, error)

HandleFDKVTx retrieves a transaction by txId in file block archived config block's tx, or returns nil if none exists. this tx is moved to kvDB while archive before

@Description:
@receiver b
@return *commonPb.Transaction
@return error

func ParseFBTxIdBlockInfo

func ParseFBTxIdBlockInfo(value []byte) (height uint64, blockHash []byte, txIndex uint32, timestamp int64,
	txFileIndex *storePb.StoreInfo, err error)

ParseFBTxIdBlockInfo retrieve TransactionStoreInfo

@Description:
@param value
@return height
@return blockHash
@return txIndex
@return timestamp
@return txFileIndex
@return err

func ParseTxIdBlockInfo

func ParseTxIdBlockInfo(value []byte) (height uint64, blockHash []byte, txIndex uint32, timestamp int64, err error)

ParseTxIdBlockInfo return height,blockHash,txIndex,timestamp

@Description:
@param value
@return height
@return blockHash
@return txIndex
@return timestamp
@return err

func ParseTxIdBlockInfoOld

func ParseTxIdBlockInfoOld(value []byte) (height uint64, blockHash []byte, txIndex uint32, err error)

ParseTxIdBlockInfoOld return height,blockHash,txIndex

@Description:
@param value
@return height
@return blockHash
@return txIndex
@return err

Types

This section is empty.

Jump to

Keyboard shortcuts

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