util

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OmitMessage = "  (...... logger omit %d character ......)  "
)

Variables

View Source
var Chain33CoinSymbol = `CoinSymbol="%s"
`

Chain33CoinSymbol ...

View Source
var Chain33DefaultConfig = `` /* 9552-byte string literal not displayed */

Chain33DefaultConfig Chain33 Default Config

View Source
var Chain33TitleFmt = `Title="%s"
`

Chain33TitleFmt ...

View Source
var Chain33TitleM = `
Title="bityuan"
`

Chain33TitleM ...

View Source
var Chain33TitleP = `
Title="user.p.xx."
`

Chain33TitleP ...

View Source
var Chain33V165 = `` /* 2855-byte string literal not displayed */

Chain33V165 chain33 1.65的配置 支持不指定配置文件, 可以更方便的使用

View Source
var ConvertEsBulk bool

ConvertEsBulk 数据解析结果存储的ES 是否选择批量写入

View Source
var ConvertServerStatus = &convertServerStatus{}
View Source
var LastSyncSeqCache = &lastSyncSeqCache{number: -1}

Functions

func AddressConvert added in v1.6.0

func AddressConvert(address string) string

AddressConvert 对地址进行转化 eth 格式地址, 都转化成小写格式

func CombineMap

func CombineMap(mapping, typ string, version int32) (string, error)

组合mapping结构

func CompressContent

func CompressContent(s string) string

CompressContent process max output length

func DumpEnv

func DumpEnv(env *db.TxEnv, check bool) (string, int64)

DumpEnv dump txs for unit test

func ESCheckAndRepair

func ESCheckAndRepair(cfg *proto.ConfigNew, EsWrite escli.ESClient) error

func ErrLogger

func ErrLogger(name string) *log15.Handler

ErrLogger log error

func GenEnv

func GenEnv(hexBlock string, index int64) (*db.TxEnv, error)

GenEnv gen env for test

func GetStack

func GetStack() string

func InitChain33

func InitChain33(title, symbol, configFile string)

InitChain33 初始化chain33

func InitConvertEsBulk

func InitConvertEsBulk(bulk bool)

func InitIndex

func InitIndex(cli db.DBCreator, index, typ, mapping string) error

InitIndex create index/type mapping if not exist

func InitLastSyncSeqCache

func InitLastSyncSeqCache(client escli.ESClient, id string, startSeq int64) error

func InitMapSet

func InitMapSet(esVersion int32, esIndex *proto.ESIndex)

func LastSyncSeq

func LastSyncSeq(client escli.ESClient, id string) (int64, error)

GetLastSyncSeq 获得最后同步的seq

func LogFmtFormat

func LogFmtFormat() log15.Format

LogFmtFormat copy from log15.LogfmtFormat(), add max output length process: CompressContent

func NewLastRecord

func NewLastRecord(id string, seq int64) *block.LastSyncSeqRecord

NewLastRecord create LastSyncSeqRecord

func NormalLogger

func NormalLogger(name string, logLevel string) *log15.Handler

NormalLogger all log

func PositionID

func PositionID(exec string, height, index int64) string

PositionID 日志用, 定位问题

func SaveToES

func SaveToES(client escli.ESClient, blockItems []db.Record) error

Save 保存convert后的结果到ES

func SaveToESSelectBulk

func SaveToESSelectBulk(client escli.ESClient, blockItems []db.Record, bulk bool) error

func SetupLog

func SetupLog(name string, logLevel string)

SetupLog Setup Log

Types

type AppConvert

type AppConvert interface {
	ConvertBlock(blockSeq *block.Seq, detail *types.BlockDetail) ([]db.Record, error)
	RecoverStats(client escli.ESClient, lastSeq int64) error
}

AppConvert for application 随着需求增加,需要各种各样的解析。由app 提供, 可以更灵活的实现

type ModuleConvert

type ModuleConvert struct {
	Title    string
	Name     string
	StartSeq int64
	// 强制或建议从StartSeq 开始同步, 强制为了测试, 建议是因为之前seq没有需要处理的交易
	ForceSeq    bool
	WriteDB     escli.ESClient
	SeqStore    store.SeqStore
	SeqNumStore store.SeqNumStore
	AppConvert
}

ModuleConvert 具体模块填上这个结构提, 由 Proc 控制流程

func (*ModuleConvert) BlockProc

func (mod *ModuleConvert) BlockProc()

BlockProc deal block

func (*ModuleConvert) SingleDealBlock

func (mod *ModuleConvert) SingleDealBlock(blockSeq *block.Seq) ([]db.Record, error)

SingleDealBlock 处理区块时只处理当前区块,不添加lastRecord

Directories

Path Synopsis
cli

Jump to

Keyboard shortcuts

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