utils

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddArchiveFlags

func AddArchiveFlags(objectName string, flags *pflag.FlagSet)

AddArchiveFlags adds the history archive specific flags: start-ledger, output, and limit

func AddBucketFlags

func AddBucketFlags(objectName string, flags *pflag.FlagSet)

AddBucketFlags adds the bucket list specifc flags: output

func AddCloudStorageFlags

func AddCloudStorageFlags(flags *pflag.FlagSet)

AddCloudStorageFlags adds the cloud storage releated flags: cloud-storage-bucket, cloud-credentials

func AddCommonFlags

func AddCommonFlags(flags *pflag.FlagSet)

AddCommonFlags adds the flags common to all commands: end-ledger, stdout, and strict-export

func AddCoreFlags

func AddCoreFlags(flags *pflag.FlagSet, defaultFolder string)

AddCoreFlags adds the captive core specific flags: core-executable, core-config, batch-size, and output flags

func AddExportTypeFlags

func AddExportTypeFlags(flags *pflag.FlagSet)

AddExportTypeFlags adds the captive core specifc flags: export-{type} flags

func AddLPOperations

func AddLPOperations(txMeta []xdr.OperationMeta, AssetA, AssetB xdr.Asset) []xdr.OperationMeta

func ConvertStroopValueToReal

func ConvertStroopValueToReal(input xdr.Int64) float64

ConvertStroopValueToReal converts a value in stroops, the smallest amount unit, into real units

func CreateBackend

func CreateBackend(start, end uint32, archiveURLs []string) (historyArchiveBackend, error)

func CreateHistoryArchiveClient

func CreateHistoryArchiveClient(archiveURLS []string) (historyarchive.ArchiveInterface, error)

func CreateSampleResultMeta

func CreateSampleResultMeta(successful bool, subOperationCount int) xdr.TransactionResultMeta

CreateSampleResultMeta creates Transaction results with the desired success flag and number of sub operation results

func CreateSampleResultPair

func CreateSampleResultPair(successful bool, subOperationCount int) xdr.TransactionResultPair

func CreateSampleTx

func CreateSampleTx(sequence int64, operationCount int) xdr.TransactionEnvelope

CreateSampleTx creates a transaction with a single operation (BumpSequence), the min base fee, and infinite timebounds

func CreateSampleTxMeta

func CreateSampleTxMeta(subOperationCount int, AssetA, AssetB xdr.Asset) *xdr.TransactionMetaV1

func ExtractEntryFromChange

func ExtractEntryFromChange(change ingest.Change) (xdr.LedgerEntry, xdr.LedgerEntryChangeType, bool, error)

ExtractEntryFromChange gets the most recent state of an entry from an ingestio change, as well as if the entry was deleted

func ExtractLedgerCloseTime

func ExtractLedgerCloseTime(ledger xdr.LedgerHeaderHistoryEntry) (time.Time, error)

ExtractLedgerCloseTime gets the close time of the provided ledger

func GetAccountAddressFromMuxedAccount

func GetAccountAddressFromMuxedAccount(account xdr.MuxedAccount) (string, error)

GetAccountAddressFromMuxedAccount takes in a muxed account and returns the address of the account

func GetCheckpointNum

func GetCheckpointNum(seq, maxSeq uint32) (uint32, error)

GetCheckpointNum gets the ledger sequence number of the checkpoint containing the provided ledger. If the checkpoint does not exist, an error is returned

func GetCloseTime

func GetCloseTime(lcm xdr.LedgerCloseMeta) (time.Time, error)

func GetLatestLedgerSequence

func GetLatestLedgerSequence(archiveURLs []string) (uint32, error)

GetLatestLedgerSequence returns the latest ledger sequence

func GetMostRecentCheckpoint

func GetMostRecentCheckpoint(seq uint32) uint32

GetMostRecentCheckpoint returns the most recent checkpoint before the provided ledger

func HashToHexString

func HashToHexString(inputHash xdr.Hash) string

HashToHexString is utility function that converts and xdr.Hash type to a hex string

func LedgerEntryToLedgerKeyHash

func LedgerEntryToLedgerKeyHash(ledgerEntry xdr.LedgerEntry) string

func MustArchiveFlags

func MustArchiveFlags(flags *pflag.FlagSet, logger *EtlLogger) (startNum uint32, path string, limit int64)

MustArchiveFlags gets the values of the the history archive specific flags: start-ledger, output, and limit

func MustBucketFlags

func MustBucketFlags(flags *pflag.FlagSet, logger *EtlLogger) (path string)

MustBucketFlags gets the values of the bucket list specific flags: output

func MustCloudStorageFlags

func MustCloudStorageFlags(flags *pflag.FlagSet, logger *EtlLogger) (bucket, credentials, provider string)

MustCloudStorageFlags gets the values of the bucket list specific flags: cloud-storage-bucket, cloud-credentials

func MustCommonFlags

func MustCommonFlags(flags *pflag.FlagSet, logger *EtlLogger) (endNum uint32, strictExport, isTest bool, isFuture bool, extra map[string]string)

MustCommonFlags gets the values of the the flags common to all commands: end-ledger and strict-export. If any do not exist, it stops the program fatally using the logger

func MustCoreFlags

func MustCoreFlags(flags *pflag.FlagSet, logger *EtlLogger) (execPath, configPath string, startNum, batchSize uint32, path string)

MustCoreFlags gets the values for the core-executable, core-config, start ledger batch-size, and output flags. If any do not exist, it stops the program fatally using the logger

func MustExportTypeFlags

func MustExportTypeFlags(flags *pflag.FlagSet, logger *EtlLogger) map[string]bool

MustExportTypeFlags gets the values for the export-accounts, export-offers, and export-trustlines flags. If any do not exist, it stops the program fatally using the logger func MustExportTypeFlags(flags *pflag.FlagSet, logger *EtlLogger) (exportAccounts, exportOffers, exportTrustlines, exportPools, exportBalances, exportContractCode, exportContractData, exportConfigSettings, exportTtl bool) {

func PanicOnError

func PanicOnError(err error)

PanicOnError is a function that panics if the provided error is not nil

func TimePointToUTCTimeStamp

func TimePointToUTCTimeStamp(providedTime xdr.TimePoint) (time.Time, error)

TimePointToUTCTimeStamp takes in an xdr TimePoint and converts it to a time.Time struct in UTC. It returns an error for negative timepoints

func ValidateLedgerRange

func ValidateLedgerRange(start, end, latestNum uint32) error

ValidateLedgerRange validates the given ledger range

Types

type CaptiveCore

type CaptiveCore interface {
	CreateCaptiveCoreBackend() (ledgerbackend.CaptiveStellarCore, error)
}

type EnvironmentDetails

type EnvironmentDetails struct {
	NetworkPassphrase string
	ArchiveURLs       []string
	BinaryPath        string
	CoreConfig        string
}

func GetEnvironmentDetails

func GetEnvironmentDetails(isTest bool, isFuture bool) (details EnvironmentDetails)

GetPassphrase returns the correct Network Passphrase based on env preference

func (EnvironmentDetails) CreateCaptiveCoreBackend

func (e EnvironmentDetails) CreateCaptiveCoreBackend() (*ledgerbackend.CaptiveStellarCore, error)

func (EnvironmentDetails) GetUnboundedLedgerCloseMeta

func (e EnvironmentDetails) GetUnboundedLedgerCloseMeta(end uint32) (xdr.LedgerCloseMeta, error)

type EtlLogger

type EtlLogger struct {
	*log.Entry
	StrictExport bool
}

func NewEtlLogger

func NewEtlLogger() *EtlLogger

func (*EtlLogger) LogError

func (l *EtlLogger) LogError(err error)

Jump to

Keyboard shortcuts

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