Documentation ¶
Index ¶
- Constants
- func CreateHistoryArchiveFromNetworkName(ctx context.Context, networkName string) (historyarchive.ArchiveInterface, error)
- func CreateLedgerCloseMeta(ledgerSeq uint32) xdr.LedgerCloseMeta
- func GetHistoryArchivesCheckPointFrequency() uint32
- func GetLatestLedgerSequenceFromHistoryArchives(archive historyarchive.ArchiveInterface) (uint32, error)
- type DataStore
- type DataStoreConfig
- type GCSDataStore
- func (b GCSDataStore) Close() error
- func (b GCSDataStore) Exists(ctx context.Context, pth string) (bool, error)
- func (b GCSDataStore) GetFile(ctx context.Context, filePath string) (io.ReadCloser, error)
- func (b GCSDataStore) PutFile(ctx context.Context, filePath string, in io.WriterTo) error
- func (b GCSDataStore) PutFileIfNotExists(ctx context.Context, filePath string, in io.WriterTo) (bool, error)
- func (b GCSDataStore) Size(ctx context.Context, pth string) (int64, error)
- type LedgerBatchConfig
- type LedgerMetaArchive
- func (f *LedgerMetaArchive) AddLedger(ledgerCloseMeta xdr.LedgerCloseMeta) error
- func (f *LedgerMetaArchive) GetEndLedgerSequence() uint32
- func (f *LedgerMetaArchive) GetLedger(sequence uint32) (xdr.LedgerCloseMeta, error)
- func (f *LedgerMetaArchive) GetLedgerCount() uint32
- func (f *LedgerMetaArchive) GetObjectKey() string
- func (f *LedgerMetaArchive) GetStartLedgerSequence() uint32
- type MockDataStore
- func (m *MockDataStore) Close() error
- func (m *MockDataStore) Exists(ctx context.Context, path string) (bool, error)
- func (m *MockDataStore) GetFile(ctx context.Context, path string) (io.ReadCloser, error)
- func (m *MockDataStore) PutFile(ctx context.Context, path string, in io.WriterTo) error
- func (m *MockDataStore) PutFileIfNotExists(ctx context.Context, path string, in io.WriterTo) (bool, error)
- func (m *MockDataStore) Size(ctx context.Context, path string) (int64, error)
- type MockResumableManager
- type ResumableManager
Constants ¶
const Pubnet = "pubnet"
const Testnet = "testnet"
Variables ¶
This section is empty.
Functions ¶
func CreateHistoryArchiveFromNetworkName ¶
func CreateHistoryArchiveFromNetworkName(ctx context.Context, networkName string) (historyarchive.ArchiveInterface, error)
func CreateLedgerCloseMeta ¶
func CreateLedgerCloseMeta(ledgerSeq uint32) xdr.LedgerCloseMeta
func GetHistoryArchivesCheckPointFrequency ¶
func GetHistoryArchivesCheckPointFrequency() uint32
func GetLatestLedgerSequenceFromHistoryArchives ¶
func GetLatestLedgerSequenceFromHistoryArchives(archive historyarchive.ArchiveInterface) (uint32, error)
Types ¶
type DataStore ¶
type DataStore interface { GetFile(ctx context.Context, path string) (io.ReadCloser, error) PutFile(ctx context.Context, path string, in io.WriterTo) error PutFileIfNotExists(ctx context.Context, path string, in io.WriterTo) (bool, error) Exists(ctx context.Context, path string) (bool, error) Size(ctx context.Context, path string) (int64, error) Close() error }
DataStore defines an interface for interacting with data storage
func NewDataStore ¶
func NewDataStore(ctx context.Context, datastoreConfig DataStoreConfig, network string) (DataStore, error)
NewDataStore factory, it creates a new DataStore based on the config type
type DataStoreConfig ¶
type GCSDataStore ¶
type GCSDataStore struct {
// contains filtered or unexported fields
}
GCSDataStore implements DataStore for GCS
func (GCSDataStore) Close ¶
func (b GCSDataStore) Close() error
Close closes the GCS client connection.
func (GCSDataStore) GetFile ¶
func (b GCSDataStore) GetFile(ctx context.Context, filePath string) (io.ReadCloser, error)
GetFile retrieves a file from the GCS bucket.
func (GCSDataStore) PutFileIfNotExists ¶
func (b GCSDataStore) PutFileIfNotExists(ctx context.Context, filePath string, in io.WriterTo) (bool, error)
PutFileIfNotExists uploads a file to GCS only if it doesn't already exist.
type LedgerBatchConfig ¶
type LedgerBatchConfig struct { LedgersPerFile uint32 `toml:"ledgers_per_file"` FilesPerPartition uint32 `toml:"files_per_partition"` FileSuffix string `toml:"file_suffix"` }
func (LedgerBatchConfig) GetObjectKeyFromSequenceNumber ¶
func (ec LedgerBatchConfig) GetObjectKeyFromSequenceNumber(ledgerSeq uint32) string
GetObjectKeyFromSequenceNumber generates the object key name from the ledger sequence number based on configuration.
func (LedgerBatchConfig) GetSequenceNumberEndBoundary ¶
func (ec LedgerBatchConfig) GetSequenceNumberEndBoundary(ledgerSeq uint32) uint32
func (LedgerBatchConfig) GetSequenceNumberStartBoundary ¶
func (ec LedgerBatchConfig) GetSequenceNumberStartBoundary(ledgerSeq uint32) uint32
type LedgerMetaArchive ¶
type LedgerMetaArchive struct { // file name ObjectKey string // Actual binary data Data xdr.LedgerCloseMetaBatch }
LedgerMetaArchive represents a file with metadata and binary data.
func NewLedgerMetaArchive ¶
func NewLedgerMetaArchive(key string, startSeq uint32, endSeq uint32) *LedgerMetaArchive
NewLedgerMetaArchive creates a new LedgerMetaArchive instance.
func (*LedgerMetaArchive) AddLedger ¶
func (f *LedgerMetaArchive) AddLedger(ledgerCloseMeta xdr.LedgerCloseMeta) error
AddLedger adds a LedgerCloseMeta to the archive.
func (*LedgerMetaArchive) GetEndLedgerSequence ¶
func (f *LedgerMetaArchive) GetEndLedgerSequence() uint32
GetEndLedgerSequence returns the ending ledger sequence of the archive.
func (*LedgerMetaArchive) GetLedger ¶
func (f *LedgerMetaArchive) GetLedger(sequence uint32) (xdr.LedgerCloseMeta, error)
func (*LedgerMetaArchive) GetLedgerCount ¶
func (f *LedgerMetaArchive) GetLedgerCount() uint32
GetLedgerCount returns the number of ledgers currently in the archive.
func (*LedgerMetaArchive) GetObjectKey ¶
func (f *LedgerMetaArchive) GetObjectKey() string
GetObjectKey returns the object key of the archive.
func (*LedgerMetaArchive) GetStartLedgerSequence ¶
func (f *LedgerMetaArchive) GetStartLedgerSequence() uint32
GetStartLedgerSequence returns the starting ledger sequence of the archive.
type MockDataStore ¶
MockDataStore is a mock implementation for the Storage interface.
func (*MockDataStore) Close ¶
func (m *MockDataStore) Close() error
func (*MockDataStore) GetFile ¶
func (m *MockDataStore) GetFile(ctx context.Context, path string) (io.ReadCloser, error)
func (*MockDataStore) PutFileIfNotExists ¶
type MockResumableManager ¶
type ResumableManager ¶
type ResumableManager interface { // Given a requested ledger range, return the first absent ledger within the // requested range of [start, end]. // // start - begin search inclusive from this ledger, must be greater than 0. // end - stop search inclusive to this ledger. // // If start=0, invalid, error will be returned. // // If end=0, is provided as a convenience, to allow requesting an effectively // dynamic end value for the range, which will be an approximation of the network's // most recent checkpointed ledger + (2 * checkpoint_frequency). // // return: // absentLedger - will be non-zero, the oldest ledger sequence between range of [start, end] // which is not populated on data store. // ok - if true, 'absentLedger' has a usable non-zero value, if false, there is no absent ledger in the requested range and 'absentLedger' is set to zero. // err - the search was cancelled due to this unexpected error, 'absentLedger' and 'ok' return values should be ignored. // // When no error, the two return values will compose the following truth table: // 1. datastore had no data in the requested range: absentLedger={start}, ok=true // 2. datastore had partial data in the requested range: absentLedger={a value > start and <= end}, ok=true // 3. datastore had all data in the requested range: absentLedger=0, ok=false FindStart(ctx context.Context, start, end uint32) (absentLedger uint32, ok bool, err error) }
func NewResumableManager ¶
func NewResumableManager(dataStore DataStore, network string, ledgerBatchConfig LedgerBatchConfig, archive historyarchive.ArchiveInterface) ResumableManager