global

package
v0.6.2-testnet Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2025 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MultiStateDBName     = "proximadb"
	TxStoreDBName        = "proximadb.txstore"
	ConfigKeyTxStoreType = "txstore.type"

	// MaxSyncPortionSlots max number of slots in the sync portion
	MaxSyncPortionSlots = 100
)
View Source
const (
	BaseTokenName       = "Proxi"
	BaseTokenNameTicker = "PRXI"
	DustTokenName       = "dust"
)
View Source
const (
	PullRepeatPeriodDefault = 2 * time.Second
	PullMaxAttemptsDefault  = 30
	PullFromNumPeersDefault = 3
)

PullTimeout maximum time allowed for the virtual txid become transaction (full vertex)

View Source
const TimeLayoutDefault = "01-02 15:04:05.000"
View Source
const TraceTag = "global"
View Source
const (
	// Version has the following structure: vA.B.C[-<label>]
	// A is the major version. It is 0 until beta. All alpha testnets are 'v0.n...'. Beta starts at 1
	// B is the minor version. Change of the version means breaking change
	// C is the subversion. Change of it means non-breaking change
	// <label> is an arbitrary label
	Version = "v0.6.2-testnet"
)

Variables

View Source
var (
	FractionHalf = Fraction{
		Numerator:   1,
		Denominator: 2,
	}

	Fraction23 = Fraction{
		Numerator:   2,
		Denominator: 3,
	}

	FractionHealthyBranch = FractionHalf

	ErrInterrupted = errors.New("interrupted by global stop")
)
View Source
var (
	CommitHash       = "N/A"
	CommitTime       = "N/A"
	CommitTimeParsed time.Time
)

Functions

func BannerString

func BannerString() string

func IsHealthyCoverageDelta

func IsHealthyCoverageDelta(coverageDelta, supply uint64, fraction Fraction) bool

IsHealthyCoverageDelta coverage delta is healthy if it is bigger than the fraction of supply

func MaintainLogs

func MaintainLogs(logFilename string, prevMode string, keepLatest int) (erasedPrev bool, savedPrev string)

func NewLogger

func NewLogger(name string, level zapcore.Level, outputs []string, timeLayout string) *zap.SugaredLogger

Types

type Fraction

type Fraction struct {
	Numerator   int
	Denominator int
}

func (*Fraction) String

func (f *Fraction) String() string

type Global

type Global struct {
	*zap.SugaredLogger
	// contains filtered or unexported fields
}

func NewDefault

func NewDefault() *Global

func NewFromConfig

func NewFromConfig() *Global

func (*Global) AssertMustError

func (l *Global) AssertMustError(err error)

func (*Global) AssertNoError

func (l *Global) AssertNoError(err error, prefix ...string)

func (*Global) Assertf

func (l *Global) Assertf(cond bool, format string, args ...any)

func (*Global) AttachmentFinished

func (l *Global) AttachmentFinished(started ...time.Time)

func (*Global) ClockCatchUpWithLedgerTime

func (l *Global) ClockCatchUpWithLedgerTime(ts base.LedgerTime)

func (*Global) Counter

func (l *Global) Counter(name string) int

func (*Global) CounterLines

func (l *Global) CounterLines(prefix ...string) *lines.Lines

func (*Global) Ctx

func (l *Global) Ctx() context.Context

func (*Global) DeadlockCatchingDisabled

func (l *Global) DeadlockCatchingDisabled() bool

func (*Global) DecCounter

func (l *Global) DecCounter(name string)

func (*Global) IncCounter

func (l *Global) IncCounter(name string)

func (*Global) Infof0

func (l *Global) Infof0(template string, args ...any)

func (*Global) Infof1

func (l *Global) Infof1(template string, args ...any)

func (*Global) Infof2

func (l *Global) Infof2(template string, args ...any)

func (*Global) InfofAtLevel

func (l *Global) InfofAtLevel(level int, template string, args ...any)

func (*Global) IsShuttingDown

func (l *Global) IsShuttingDown() bool

func (*Global) Log

func (l *Global) Log() *zap.SugaredLogger

func (*Global) MarkWorkProcessStarted

func (l *Global) MarkWorkProcessStarted(name string)

func (*Global) MarkWorkProcessStopped

func (l *Global) MarkWorkProcessStopped(name string)

func (*Global) MetricsRegistry

func (l *Global) MetricsRegistry() *prometheus.Registry

func (*Global) Outputs

func (l *Global) Outputs() []string

func (*Global) RepeatInBackground

func (l *Global) RepeatInBackground(name string, period time.Duration, fun func() bool, skipFirst ...bool)

func (*Global) RepeatSync

func (l *Global) RepeatSync(period time.Duration, fun func() bool) bool

func (*Global) StartTracingTags

func (l *Global) StartTracingTags(tags ...string)

func (*Global) Stop

func (l *Global) Stop()

func (*Global) StopTracingTag

func (l *Global) StopTracingTag(tag string)

func (*Global) Tracef

func (l *Global) Tracef(tag string, format string, args ...any)

func (*Global) TracefLog

func (l *Global) TracefLog(log *zap.SugaredLogger, tag string, format string, args ...any)

func (*Global) TxPullParameters

func (l *Global) TxPullParameters() (repeatPeriod time.Duration, maxAttempts int, numPeers int)

func (*Global) VerbosityLevel

func (l *Global) VerbosityLevel() int

func (*Global) WaitAllWorkProcessesStop

func (l *Global) WaitAllWorkProcessesStop(timeout ...time.Duration) bool

type Logging

type Logging interface {
	Log() *zap.SugaredLogger
	Outputs() []string
	Tracef(tag string, format string, args ...any)
	TracefLog(log *zap.SugaredLogger, tag string, format string, args ...any)
	StartTracingTags(tags ...string)
	// Assertf asserts only if global shutdown wasn't issued
	Assertf(cond bool, format string, args ...any)
	AssertNoError(err error, prefix ...string)
	VerbosityLevel() int
	Infof0(template string, args ...any)
	Infof1(template string, args ...any)
	Infof2(template string, args ...any)

	IncCounter(name string)
	DecCounter(nane string)
	Counter(name string) int
	CounterLines(prefix ...string) *lines.Lines
	AttachmentFinished(started ...time.Time)

	// TxPullParameters repeat after period, max attempts, num peers
	TxPullParameters() (repeatPeriod time.Duration, maxAttempts int, numPeers int)
	// DeadlockCatchingDisabled config parameter to disdable deadlock catching
	DeadlockCatchingDisabled() bool
}

type Metrics

type Metrics interface {
	MetricsRegistry() *prometheus.Registry
}

type NodeGlobal

type NodeGlobal interface {
	Logging
	StartStop
	Metrics
}

type NodeInfo

type NodeInfo struct {
	ID              peer.ID       `json:"id"`
	Version         string        `json:"version"`
	CommitHash      string        `json:"commit_hash"`
	CommitTime      string        `json:"commit_time"`
	NumStaticAlive  uint16        `json:"num_static_peers"`
	NumDynamicAlive uint16        `json:"num_dynamic_alive"`
	Sequencer       *base.ChainID `json:"sequencers,omitempty"`
}

func NodeInfoFromBytes

func NodeInfoFromBytes(data []byte) (*NodeInfo, error)

func (*NodeInfo) Bytes

func (ni *NodeInfo) Bytes() []byte

func (*NodeInfo) Lines

func (ni *NodeInfo) Lines(prefix ...string) *lines.Lines

type StartStop

type StartStop interface {
	Ctx() context.Context // global context of the node. Canceling means stopping the node
	Stop()
	IsShuttingDown() bool
	ClockCatchUpWithLedgerTime(ts base.LedgerTime)
	MarkWorkProcessStarted(name string)
	MarkWorkProcessStopped(name string)
	RepeatInBackground(name string, period time.Duration, fun func() bool, skipFirst ...bool) // runs background goroutine
	RepeatSync(period time.Duration, fun func() bool) bool                                    // repeats synchronously. Returns false if was interrupted, true otherwise
}

StartStop interface of the global objects which coordinates graceful shutdown

type TxBytesGet

type TxBytesGet interface {
	// GetTxBytesWithMetadata return empty slice on absence, otherwise returns concatenated metadata bytes and transaction bytes
	GetTxBytesWithMetadata(id *base.TransactionID) []byte
	HasTxBytes(txid *base.TransactionID) bool
}

type TxBytesPersist

type TxBytesPersist interface {
	// PersistTxBytesWithMetadata saves txBytes prefixed with metadata bytes.
	// metadata == nil is interpreted as empty metadata (one 0 byte as prefix)
	// optionally, transaction ChainID can be provided to avoid the need to parse the transaction bytes. In the latter case txid is used as DB key as is
	PersistTxBytesWithMetadata(txBytes []byte, metadata *txmetadata.TransactionMetadata, txid ...base.TransactionID) (base.TransactionID, error)
}

type TxBytesStore

type TxBytesStore interface {
	TxBytesGet
	TxBytesPersist
}

Jump to

Keyboard shortcuts

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