sqldb

package
v1.6.5 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: GPL-3.0 Imports: 29 Imported by: 0

Documentation

Overview

Package sqldb is a generated GoMock package.

Package sqldb is a generated GoMock package.

Index

Constants

View Source
const (
	// UploadObjectProgressTableName defines the gc object task table name.
	UploadObjectProgressTableName = "upload_object_progress"
	// GCObjectProgressTableName defines the gc object task table name.
	GCObjectProgressTableName = "gc_object_progress"
	// PieceHashTableName defines the piece hash table name.
	PieceHashTableName = "piece_hash"
	// IntegrityMetaTableName defines the integrity meta table name.
	IntegrityMetaTableName = "integrity_meta"

	ShadowIntegrityMetaTableName = "shadow_integrity_meta"
	// SpInfoTableName defines the SP info table name.
	SpInfoTableName = "sp_info"
	// StorageParamsTableName defines the storage params info table name.
	StorageParamsTableName = "storage_params"
	// BucketTrafficTableName defines the bucket traffic table name, which is used for recoding the used quota by bucket.
	BucketTrafficTableName = "bucket_traffic"
	// ReadRecordTableName defines the read record table name.
	ReadRecordTableName = "read_record"
	// ServiceConfigTableName defines the SP configuration table name.
	ServiceConfigTableName = "service_config"
	// OffChainAuthKeyTableName defines the off chain auth key table name.
	OffChainAuthKeyTableName = "off_chain_auth_key"
	// OffChainAuthKeyV2TableName defines the off chain auth key table name v2 version.
	OffChainAuthKeyV2TableName = "off_chain_auth_key_v2"
	// PutObjectSuccessTableName  defines the event of successfully putting object
	PutObjectSuccessTableName = "put_object_success_event_log"
	// PutObjectEventTableName defines the event of putting object
	PutObjectEventTableName = "put_object_event_log"
	// UploadTimeoutTableName defines the event of uploading object to primary sp timeout
	UploadTimeoutTableName = "upload_timeout_event_log"
	// UploadFailedTableName defines the event of unsuccessfully uploading object to primary sp
	UploadFailedTableName = "upload_failed_event_log"
	// ReplicateTimeoutTableName defines the event of replicating object to secondary sp timeout
	ReplicateTimeoutTableName = "replicate_timeout_event_log"
	// ReplicateFailedTableName defines the event of unsuccessfully uploading object to secondary sp
	ReplicateFailedTableName = "replicate_failed_event_log"
	// SealTimeoutTableName defines the event of sealing object timeout
	SealTimeoutTableName = "seal_timeout_event_log"
	// SealFailedTableName defines the event of unsuccessfully sealing object timeout
	SealFailedTableName = "seal_failed_event_log"
	// MigrateSubscribeProgressTableName defines the progress of subscribe migrate event.
	MigrateSubscribeProgressTableName = "migrate_subscribe_progress"
	// SwapOutTableName is the swap out unit table.
	SwapOutTableName = "swap_out_unit"
	// MigrateGVGTableName defines the progress of subscribe migrate event.
	MigrateGVGTableName = "migrate_gvg"
	// RecoverGVGStatsTableName is for successor SP to keep track of recovering objects in a virtual group family
	RecoverGVGStatsTableName = "recover_gvg_stats"

	RecoverFailedObjectTableName = "recover_failed_object"
	// MigrateBucketProgressTableName defines the progress of migrate bucket.
	MigrateBucketProgressTableName = "migrate_bucket_progress"
)

define table name constant.

View Source
const (
	SPExitProgressKey          = "sp_exit_progress"
	SwapOutProgressKey         = "swap_out_progress"
	BucketMigrateProgressKey   = "bucket_migrate_progress"
	BucketMigrateGCProgressKey = "bucket_migrate_gc_progress"
)
View Source
const (
	// SPDBSuccessGetObjectIntegrity defines the metrics label of successfully get object integrity
	SPDBSuccessGetObjectIntegrity = "get_object_integrity_meta_success"
	// SPDBFailureGetObjectIntegrity defines the metrics label of unsuccessfully get object integrity
	SPDBFailureGetObjectIntegrity = "get_object_integrity_meta_failure"
	// SPDBSuccessSetObjectIntegrity defines the metrics label of successfully set object integrity
	SPDBSuccessSetObjectIntegrity = "set_object_integrity_meta_success"
	// SPDBFailureSetObjectIntegrity defines the metrics label of unsuccessfully set object integrity
	SPDBFailureSetObjectIntegrity = "set_object_integrity_meta_failure"
	// SPDBSuccessDelObjectIntegrity defines the metrics label of successfully del object integrity
	SPDBSuccessDelObjectIntegrity = "del_object_integrity_meta_success"
	// SPDBFailureDelObjectIntegrity defines the metrics label of unsuccessfully del object integrity
	SPDBFailureDelObjectIntegrity = "del_object_integrity_meta_failure"
	// SPDBSuccessListObjectIntegrity defines the metrics label of successfully list object integrity
	SPDBSuccessListObjectIntegrity = "list_object_integrity_meta_success"
	// SPDBFailureListObjectIntegrity defines the metrics label of unsuccessfully list object integrity
	SPDBFailureListObjectIntegrity = "list_object_integrity_meta_failure"

	// SPDBSuccessUpdatePieceChecksum defines the metrics label of successfully update object piece checksum
	SPDBSuccessUpdatePieceChecksum = "append_object_checksum_integrity_success"
	// SPDBFailureUpdatePieceChecksum defines the metrics label of unsuccessfully update object piece checksum
	SPDBFailureUpdatePieceChecksum = "append_object_checksum_integrity_failure"
	// SPDBSuccessUpdateIntegrityChecksum defines the metrics label of successfully update object integrity checksum
	SPDBSuccessUpdateIntegrityChecksum = "append_object_checksum_integrity_success"
	// SPDBFailureUpdateIntegrityChecksum defines the metrics label of unsuccessfully update object integrity checksum
	SPDBFailureUpdateIntegrityChecksum = "append_object_checksum_integrity_failure"
	// SPDBSuccessGetReplicatePieceChecksum defines the metrics label of successfully get replicate piece checksum
	SPDBSuccessGetReplicatePieceChecksum = "get_replicate_piece_checksum_success"
	// SPDBFailureGetReplicatePieceChecksum defines the metrics label of unsuccessfully get replicate piece checksum
	SPDBFailureGetReplicatePieceChecksum = "get_replicate_piece_checksum_failure"
	// SPDBSuccessSetReplicatePieceChecksum defines the metrics label of successfully set replicate piece checksum
	SPDBSuccessSetReplicatePieceChecksum = "set_replicate_piece_checksum_success"
	// SPDBFailureSetReplicatePieceChecksum defines the metrics label of unsuccessfully set replicate piece checksum
	SPDBFailureSetReplicatePieceChecksum = "set_replicate_piece_checksum_failure"
	// SPDBSuccessDelReplicatePieceChecksum defines the metrics label of successfully del replicate piece checksum
	SPDBSuccessDelReplicatePieceChecksum = "del_replicate_piece_checksum_success"
	// SPDBFailureDelReplicatePieceChecksum defines the metrics label of unsuccessfully del replicate piece checksum
	SPDBFailureDelReplicatePieceChecksum = "del_replicate_piece_checksum_failure"

	// SPDBSuccessGetAllReplicatePieceChecksum defines the metrics label of successfully get all replicate piece checksum
	SPDBSuccessGetAllReplicatePieceChecksum = "get_all_replicate_piece_checksum_success"
	// SPDBFailureGetAllReplicatePieceChecksum defines the metrics label of unsuccessfully get all replicate piece checksum
	SPDBFailureGetAllReplicatePieceChecksum = "get_all_replicate_piece_checksum_failure"
	// SPDBSuccessDelAllReplicatePieceChecksum defines the metrics label of successfully del all replicate piece checksum
	SPDBSuccessDelAllReplicatePieceChecksum = "del_all_replicate_piece_checksum_success"
	// SPDBFailureDelAllReplicatePieceChecksum defines the metrics label of unsuccessfully del all replicate piece checksum
	SPDBFailureDelAllReplicatePieceChecksum = "del_all_replicate_piece_checksum_failure"

	// SPDBSuccessListReplicatePieceChecksumByObjectID defines the metrics label of successfully list replicate piece checksum by object id
	SPDBSuccessListReplicatePieceChecksumByObjectID = "list_replicate_piece_checksum_by_object_id_success"
	// SPDBFailureListReplicatePieceChecksumByObjectID defines the metrics label of unsuccessfully list replicate piece checksum by object id
	SPDBFailureListReplicatePieceChecksumByObjectID = "list_replicate_piece_checksum_by_object_id_failure"
)
View Source
const (
	IntegrityMetasNumberOfShards = 64
	ReasonableTableSize          = 5_000_000
	ListObjectsDefaultSize       = 1000
)
View Source
const (
	// SpDBUser defines env variable name for sp db user name.
	SpDBUser = "SP_DB_USER"
	// SpDBPasswd defines env variable name for sp db user passwd.
	SpDBPasswd = "SP_DB_PASSWORD"
	// SpDBAddress defines env variable name for sp db address.
	SpDBAddress = "SP_DB_ADDRESS"
	// SpDBDatabase defines env variable name for sp db database.
	SpDBDatabase = "SP_DB_DATABASE"

	// DefaultConnMaxLifetime defines the default max liveliness time of connection.
	DefaultConnMaxLifetime = 2048
	// DefaultConnMaxIdleTime defines the default max idle time of connection.
	DefaultConnMaxIdleTime = 2048
	// DefaultMaxIdleConns defines the default max number of idle connections.
	DefaultMaxIdleConns = 2048
	// DefaultMaxOpenConns defines the default max number of open connections.
	DefaultMaxOpenConns = 2048
	// DefaultEnableTracePutEvent defines the default max number of open connections.
	DefaultEnableTracePutEvent = true
)
View Source
const (
	// SPDBSuccessCheckQuotaAndAddReadRecord defines the metrics label of successfully check and add read record
	SPDBSuccessCheckQuotaAndAddReadRecord = "check_and_add_read_record_success"
	// SPDBFailureCheckQuotaAndAddReadRecord defines the metrics label of unsuccessfully check and add read record
	SPDBFailureCheckQuotaAndAddReadRecord = "check_and_add_read_record_failure"
	// SPDBSuccessGetBucketTraffic defines the metrics label of successfully get bucket traffic
	SPDBSuccessGetBucketTraffic = "get_bucket_traffic_success"
	// SPDBFailureGetBucketTraffic defines the metrics label of unsuccessfully get bucket traffic
	SPDBFailureGetBucketTraffic = "get_bucket_traffic_failure"
	// SPDBSuccessGetReadRecord defines the metrics label of successfully get read record
	SPDBSuccessGetReadRecord = "get_read_record_success"
	// SPDBFailureGetReadRecord defines the metrics label of unsuccessfully get read record
	SPDBFailureGetReadRecord = "get_read_record_failure"
	// SPDBSuccessGetBucketReadRecord defines the metrics label of successfully get bucket read record
	SPDBSuccessGetBucketReadRecord = "get_bucket_read_record_success"
	// SPDBFailureGetBucketReadRecord defines the metrics label of unsuccessfully get bucket read record
	SPDBFailureGetBucketReadRecord = "get_bucket_read_record_failure"
	// SPDBSuccessGetObjectReadRecord defines the metrics label of successfully get object read record
	SPDBSuccessGetObjectReadRecord = "get_object_read_record_success"
	// SPDBFailureGetObjectReadRecord defines the metrics label of unsuccessfully get object read record
	SPDBFailureGetObjectReadRecord = "get_object_read_record_failure"
	// SPDBSuccessGetUserReadRecord defines the metrics label of successfully get user read record
	SPDBSuccessGetUserReadRecord = "get_user_read_record_success"
	// SPDBFailureGetUserReadRecord defines the metrics label of unsuccessfully get user read record
	SPDBFailureGetUserReadRecord = "get_user_read_record_failure"
)
View Source
const ListShadowIntegrityMetaDefaultSize = 5
View Source
const (
	TableAlreadyExistsErrorPrefix = "Error 1050 (42S01)"
)

define error name constant.

Variables

View Source
var (
	// ErrCheckQuotaEnough defines check quota is enough
	ErrCheckQuotaEnough = errors.New("quota is not enough")
)
View Source
var (
	ErrDuplicateEntryCode = 1062
)

Functions

func GetCurrentTimestampUs

func GetCurrentTimestampUs() int64

GetCurrentTimestampUs return a microsecond timestamp

func GetCurrentUnixTime

func GetCurrentUnixTime() int64

GetCurrentUnixTime return a second timestamp

func GetCurrentYearMonth

func GetCurrentYearMonth() string

GetCurrentYearMonth get current year and month

func GetIntegrityMetasShardNumberByBucketName added in v0.2.3

func GetIntegrityMetasShardNumberByBucketName(objectID uint64) uint64

GetIntegrityMetasShardNumberByBucketName Allocate each shard table with 5,000,000 continuous entry before using the next shard table

func GetIntegrityMetasTableName added in v0.2.3

func GetIntegrityMetasTableName(objectID uint64) string

func GetIntegrityMetasTableNameByShardNumber added in v0.2.3

func GetIntegrityMetasTableNameByShardNumber(shard int) string

func InitDB

func InitDB(config *config.SQLDBConfig) (*gorm.DB, error)

InitDB init a db instance

func IsNextMonth added in v0.2.5

func IsNextMonth(firstYearMonth, secondYearMonth string) bool

IsNextMonth judge if the firstYearMonth is the next month of secondYearMonth

func LoadDBConfigFromEnv

func LoadDBConfigFromEnv(config *config.SQLDBConfig)

LoadDBConfigFromEnv load db user and password from env vars

func MysqlErrCode added in v0.2.2

func MysqlErrCode(err error) int

func OverrideConfigVacancy added in v0.1.1

func OverrideConfigVacancy(config *config.SQLDBConfig)

OverrideConfigVacancy override the SQLDB param zero value

func TimeToYearMonth

func TimeToYearMonth(t time.Time) string

TimeToYearMonth convent time.Time to YYYY-MM string

func TimestampSecToTime

func TimestampSecToTime(timeUnix int64) time.Time

TimestampSecToTime convert a second timestamp to time.Time

func TimestampUsToTime

func TimestampUsToTime(ts int64) time.Time

TimestampUsToTime convert a microsecond timestamp to time.Time

func TimestampYearMonth added in v0.2.4

func TimestampYearMonth(ts int64) string

TimestampYearMonth convert a microsecond timestamp to YYYY-MM string

Types

type Batch

type Batch interface {
	// Put inserts the given value into the key-value data store.
	Put(key interface{}, value interface{}) error

	// Delete removes the key from the key-value data store.
	Delete(key interface{}) error

	// ValueSize retrieves the amount of data queued up for writing.
	ValueSize() int

	// Write flushes any accumulated data to disk.
	Write() error

	// Reset resets the batch for reuse.
	Reset()
}

Batch is a write-only database that commits changes to its host database when Write is called. A batch cannot be used concurrently.

type Batcher

type Batcher interface {
	// NewBatch creates a write-only database that buffers changes to its host db
	// until a final write is called.
	NewBatch() Batch

	// NewBatchWithSize creates a write-only database batch with pre-allocated buffer.
	NewBatchWithSize(size int) Batch
}

Batcher wraps the NewBatch method of a backing data store.

type BucketTrafficTable

type BucketTrafficTable struct {
	BucketID                     uint64 `gorm:"primary_key"`
	Month                        string `gorm:"primary_key"`
	BucketName                   string
	ReadConsumedSize             uint64 // indicates the consumed chargedQuota of this month
	FreeQuotaConsumedSize        uint64 // indicates the consumed free quota size of this month
	MonthlyFreeQuotaConsumedSize uint64 // indicates the consumed monthly free quota size of this month
	FreeQuotaSize                uint64 // indicate the remained free quota
	ChargedQuotaSize             uint64 // indicate the greenfield chain bucket charged quota
	MonthlyQuotaSize             uint64 // indicate the remained monthly free quota
	ModifiedTime                 time.Time
}

BucketTrafficTable table schema

func (BucketTrafficTable) TableName

func (BucketTrafficTable) TableName() string

TableName is used to set BucketTraffic Schema's table name in database

type ByRedundancyIndexAndObjectID added in v1.2.0

type ByRedundancyIndexAndObjectID []*corespdb.IntegrityMeta

func (ByRedundancyIndexAndObjectID) Len added in v1.2.0

func (ByRedundancyIndexAndObjectID) Less added in v1.2.0

func (b ByRedundancyIndexAndObjectID) Less(i, j int) bool

Less we want to sort as ascending here

func (ByRedundancyIndexAndObjectID) Swap added in v1.2.0

func (b ByRedundancyIndexAndObjectID) Swap(i, j int)

type GCObjectProgressTable added in v0.2.2

type GCObjectProgressTable struct {
	TaskKey               string `gorm:"primary_key"`
	StartGCBlockID        uint64
	EndGCBlockID          uint64
	CurrentGCBlockID      uint64
	LastDeletedObjectID   uint64
	CreateTimestampSecond int64
	UpdateTimestampSecond int64 `gorm:"index:update_timestamp_index"`
}

GCObjectProgressTable table schema

func (GCObjectProgressTable) TableName added in v0.2.2

func (GCObjectProgressTable) TableName() string

TableName is used to set GCObjectProgressTable Schema's table name in database

type IntegrityMetaTable

type IntegrityMetaTable struct {
	ObjectID          uint64 `gorm:"primary_key"`
	RedundancyIndex   int32  `gorm:"primary_key"`
	IntegrityChecksum string
	PieceChecksumList string
	ObjectSize        uint64
}

IntegrityMetaTable table schema

func (IntegrityMetaTable) TableName

func (IntegrityMetaTable) TableName() string

TableName is used to set IntegrityMetaTable schema's table name in database

type Iteratee

type Iteratee interface {
	// NewIterator creates a binary-alphabetical iterator over a subset
	// of database content with a particular key prefix, starting at a particular
	// initial key (or after, if it does not exist).
	//
	// Note: This method assumes that the prefix is NOT part of the start, so there's
	// no need for the caller to prepend the prefix to the start
	NewIterator(start interface{}) Iterator
}

Iteratee wraps the NewIterator methods of a backing data store.

type Iterator

type Iterator interface {
	// IsValid return true if current element is valid.
	IsValid() bool

	// Next move to next
	Next()

	// Error returns any accumulated error. Exhausting all the key/value pairs
	// is not considered to be an error.
	Error() error

	// Key returns the key of the current key/value pair, or nil if done. The caller
	// should not modify the contents of the returned slice, and its contents may
	// change on the next call to Next.
	Key() interface{}

	// Value returns the value of the current key/value pair, or nil if done. The
	// caller should not modify the contents of the returned slice, and its contents
	// may change on the next call to Next.
	Value() interface{}

	// Release releases associated resources. Release should always succeed and can
	// be called multiple times without causing error.
	Release()
}

Iterator iterates over a database's key/value pairs in ascending key order.

When it encounters an error any seek will return false and will yield no key/ value pairs. The error can be queried by calling the Error method. Calling Release is still necessary.

An iterator must be released after use, but it is not necessary to read an iterator until exhaustion. An iterator is not safe for concurrent use, but it is safe to use multiple iterators concurrently.

type MigrateBucketProgressTable added in v1.3.0

type MigrateBucketProgressTable struct {
	BucketID              uint64 `gorm:"primary_key"`
	SubscribedBlockHeight uint64 `gorm:"primary_key"`
	MigrationState        int    `gorm:"migration_state"`

	TotalGvgNum            uint32 // Total number of GVGs that need to be migrated
	MigratedFinishedGvgNum uint32 // Number of successfully migrated GVGs
	GcFinishedGvgNum       uint32 // Number of successfully gc finished GVGs

	PreDeductedQuota uint64 // Quota pre-deducted by the source sp in the pre-migrate bucket phase
	RecoupQuota      uint64 // In case of migration failure, the dest sp recoup the quota for the source sp

	LastGcObjectID uint64 // After bucket migration is complete, the progress of GC, up to which object is GC performed.
	LastGcGvgID    uint64 // which GVG is GC performed.
}

MigrateBucketProgressTable table schema. used by persist bucket migration progress and meta

func (MigrateBucketProgressTable) TableName added in v1.3.0

func (MigrateBucketProgressTable) TableName() string

TableName is used to set MigrateBucketProgressTable Schema's table name in database.

type MigrateGVGTable added in v0.2.3

type MigrateGVGTable struct {
	MigrateKey               string `gorm:"primary_key"`
	SwapOutKey               string `gorm:"index:swap_out_index"`
	GlobalVirtualGroupID     uint32 `gorm:"index:gvg_index"`        // is used by sp exit/bucket migrate
	DestGlobalVirtualGroupID uint32 `gorm:"index:dest_gvg_index"`   // is used by bucket migrate
	VirtualGroupFamilyID     uint32 `gorm:"index:vgf_index"`        // is used by sp exit
	BucketID                 uint64 `gorm:"index:bucket_index"`     // is used by bucket migrate
	RedundancyIndex          int32  `gorm:"index:redundancy_index"` // is used by sp exit
	SrcSPID                  uint32
	DestSPID                 uint32
	LastMigratedObjectID     uint64
	MigrateStatus            int `gorm:"index:migrate_status_index"`
	RetryTime                int `gorm:"comment:retry_time"`
	MigratedBytesSize        uint64
}

MigrateGVGTable table schema. sp exit, bucket migrate

func (MigrateGVGTable) TableName added in v0.2.3

func (MigrateGVGTable) TableName() string

TableName is used to set MigrateGVGTable Schema's table name in database.

type MigrateSubscribeProgressTable added in v0.2.3

type MigrateSubscribeProgressTable struct {
	EventName                 string `gorm:"primary_key"`
	LastSubscribedBlockHeight uint64
}

MigrateSubscribeProgressTable table schema.

func (MigrateSubscribeProgressTable) TableName added in v0.2.3

TableName is used to set MigrateSubscribeEventProgressTable Schema's table name in database.

type MockBatch added in v0.2.4

type MockBatch struct {
	// contains filtered or unexported fields
}

MockBatch is a mock of Batch interface.

func NewMockBatch added in v0.2.4

func NewMockBatch(ctrl *gomock.Controller) *MockBatch

NewMockBatch creates a new mock instance.

func (*MockBatch) Delete added in v0.2.4

func (m *MockBatch) Delete(key any) error

Delete mocks base method.

func (*MockBatch) EXPECT added in v0.2.4

func (m *MockBatch) EXPECT() *MockBatchMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockBatch) Put added in v0.2.4

func (m *MockBatch) Put(key, value any) error

Put mocks base method.

func (*MockBatch) Reset added in v0.2.4

func (m *MockBatch) Reset()

Reset mocks base method.

func (*MockBatch) ValueSize added in v0.2.4

func (m *MockBatch) ValueSize() int

ValueSize mocks base method.

func (*MockBatch) Write added in v0.2.4

func (m *MockBatch) Write() error

Write mocks base method.

type MockBatchMockRecorder added in v0.2.4

type MockBatchMockRecorder struct {
	// contains filtered or unexported fields
}

MockBatchMockRecorder is the mock recorder for MockBatch.

func (*MockBatchMockRecorder) Delete added in v0.2.4

func (mr *MockBatchMockRecorder) Delete(key any) *gomock.Call

Delete indicates an expected call of Delete.

func (*MockBatchMockRecorder) Put added in v0.2.4

func (mr *MockBatchMockRecorder) Put(key, value any) *gomock.Call

Put indicates an expected call of Put.

func (*MockBatchMockRecorder) Reset added in v0.2.4

func (mr *MockBatchMockRecorder) Reset() *gomock.Call

Reset indicates an expected call of Reset.

func (*MockBatchMockRecorder) ValueSize added in v0.2.4

func (mr *MockBatchMockRecorder) ValueSize() *gomock.Call

ValueSize indicates an expected call of ValueSize.

func (*MockBatchMockRecorder) Write added in v0.2.4

func (mr *MockBatchMockRecorder) Write() *gomock.Call

Write indicates an expected call of Write.

type MockBatcher added in v0.2.4

type MockBatcher struct {
	// contains filtered or unexported fields
}

MockBatcher is a mock of Batcher interface.

func NewMockBatcher added in v0.2.4

func NewMockBatcher(ctrl *gomock.Controller) *MockBatcher

NewMockBatcher creates a new mock instance.

func (*MockBatcher) EXPECT added in v0.2.4

func (m *MockBatcher) EXPECT() *MockBatcherMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockBatcher) NewBatch added in v0.2.4

func (m *MockBatcher) NewBatch() Batch

NewBatch mocks base method.

func (*MockBatcher) NewBatchWithSize added in v0.2.4

func (m *MockBatcher) NewBatchWithSize(size int) Batch

NewBatchWithSize mocks base method.

type MockBatcherMockRecorder added in v0.2.4

type MockBatcherMockRecorder struct {
	// contains filtered or unexported fields
}

MockBatcherMockRecorder is the mock recorder for MockBatcher.

func (*MockBatcherMockRecorder) NewBatch added in v0.2.4

func (mr *MockBatcherMockRecorder) NewBatch() *gomock.Call

NewBatch indicates an expected call of NewBatch.

func (*MockBatcherMockRecorder) NewBatchWithSize added in v0.2.4

func (mr *MockBatcherMockRecorder) NewBatchWithSize(size any) *gomock.Call

NewBatchWithSize indicates an expected call of NewBatchWithSize.

type MockIteratee added in v0.2.4

type MockIteratee struct {
	// contains filtered or unexported fields
}

MockIteratee is a mock of Iteratee interface.

func NewMockIteratee added in v0.2.4

func NewMockIteratee(ctrl *gomock.Controller) *MockIteratee

NewMockIteratee creates a new mock instance.

func (*MockIteratee) EXPECT added in v0.2.4

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockIteratee) NewIterator added in v0.2.4

func (m *MockIteratee) NewIterator(start any) Iterator

NewIterator mocks base method.

type MockIterateeMockRecorder added in v0.2.4

type MockIterateeMockRecorder struct {
	// contains filtered or unexported fields
}

MockIterateeMockRecorder is the mock recorder for MockIteratee.

func (*MockIterateeMockRecorder) NewIterator added in v0.2.4

func (mr *MockIterateeMockRecorder) NewIterator(start any) *gomock.Call

NewIterator indicates an expected call of NewIterator.

type MockIterator added in v0.2.4

type MockIterator struct {
	// contains filtered or unexported fields
}

MockIterator is a mock of Iterator interface.

func NewMockIterator added in v0.2.4

func NewMockIterator(ctrl *gomock.Controller) *MockIterator

NewMockIterator creates a new mock instance.

func (*MockIterator) EXPECT added in v0.2.4

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockIterator) Error added in v0.2.4

func (m *MockIterator) Error() error

Error mocks base method.

func (*MockIterator) IsValid added in v0.2.4

func (m *MockIterator) IsValid() bool

IsValid mocks base method.

func (*MockIterator) Key added in v0.2.4

func (m *MockIterator) Key() any

Key mocks base method.

func (*MockIterator) Next added in v0.2.4

func (m *MockIterator) Next()

Next mocks base method.

func (*MockIterator) Release added in v0.2.4

func (m *MockIterator) Release()

Release mocks base method.

func (*MockIterator) Value added in v0.2.4

func (m *MockIterator) Value() any

Value mocks base method.

type MockIteratorMockRecorder added in v0.2.4

type MockIteratorMockRecorder struct {
	// contains filtered or unexported fields
}

MockIteratorMockRecorder is the mock recorder for MockIterator.

func (*MockIteratorMockRecorder) Error added in v0.2.4

func (mr *MockIteratorMockRecorder) Error() *gomock.Call

Error indicates an expected call of Error.

func (*MockIteratorMockRecorder) IsValid added in v0.2.4

func (mr *MockIteratorMockRecorder) IsValid() *gomock.Call

IsValid indicates an expected call of IsValid.

func (*MockIteratorMockRecorder) Key added in v0.2.4

Key indicates an expected call of Key.

func (*MockIteratorMockRecorder) Next added in v0.2.4

func (mr *MockIteratorMockRecorder) Next() *gomock.Call

Next indicates an expected call of Next.

func (*MockIteratorMockRecorder) Release added in v0.2.4

func (mr *MockIteratorMockRecorder) Release() *gomock.Call

Release indicates an expected call of Release.

func (*MockIteratorMockRecorder) Value added in v0.2.4

func (mr *MockIteratorMockRecorder) Value() *gomock.Call

Value indicates an expected call of Value.

type OffChainAuthKeyTable added in v0.1.2

type OffChainAuthKeyTable struct {
	UserAddress string `gorm:"primary_key"`
	Domain      string `gorm:"primary_key"`

	CurrentNonce     int32
	CurrentPublicKey string
	NextNonce        int32
	ExpiryDate       time.Time

	CreatedTime  time.Time
	ModifiedTime time.Time
}

OffChainAuthKeyTable table schema

func (OffChainAuthKeyTable) TableName added in v0.1.2

func (OffChainAuthKeyTable) TableName() string

TableName is used to set OffChainAuthKeyTable Schema's table name in database

type OffChainAuthKeyV2Table added in v1.6.0

type OffChainAuthKeyV2Table struct {
	UserAddress string `gorm:"primary_key"`
	Domain      string `gorm:"primary_key"`
	PublicKey   string `gorm:"primary_key"`

	ExpiryDate   time.Time
	CreatedTime  time.Time
	ModifiedTime time.Time
}

OffChainAuthKeyV2Table table schema

func (OffChainAuthKeyV2Table) TableName added in v1.6.0

func (OffChainAuthKeyV2Table) TableName() string

TableName is used to set OffChainAuthKeyV2 Schema's table name in database

type PieceHashTable added in v0.2.2

type PieceHashTable struct {
	ObjectID        uint64 `gorm:"primary_key"`
	SegmentIndex    uint32 `gorm:"primary_key"`
	RedundancyIndex int32  `gorm:"primary_key"`
	PieceChecksum   string
	Version         int64
}

PieceHashTable table schema

func (PieceHashTable) TableName added in v0.2.2

func (PieceHashTable) TableName() string

TableName is used to set PieceHashTable schema's table name in database

type PutObjectEventTable added in v0.2.3

type PutObjectEventTable struct {
	ID         uint64 `gorm:"primary_key;autoIncrement"`
	UpdateTime string `gorm:"index:update_time_index"`
	ObjectID   uint64 `gorm:"index:object_id_index"`
	Bucket     string `gorm:"index:bucket_index"`
	Object     string `gorm:"index:object_index"`
	State      string
	Error      string
	Logs       string
}

PutObjectEventTable table schema.

func (PutObjectEventTable) TableName added in v0.2.3

func (PutObjectEventTable) TableName() string

TableName is used to set UploadObjectProgressTable Schema's table name in database.

type PutObjectSuccessTable added in v0.2.3

type PutObjectSuccessTable struct {
	ID         uint64 `gorm:"primary_key;autoIncrement"`
	UpdateTime string `gorm:"index:update_time_index"`
	ObjectID   uint64 `gorm:"index:object_id_index"`
	Bucket     string `gorm:"index:bucket_index"`
	Object     string `gorm:"index:object_index"`
	State      string
	Error      string
	Logs       string
}

PutObjectSuccessTable table schema.

func (PutObjectSuccessTable) TableName added in v0.2.3

func (PutObjectSuccessTable) TableName() string

TableName is used to set UploadObjectProgressTable Schema's table name in database.

type ReadRecordTable

type ReadRecordTable struct {
	ReadRecordID    uint64 `gorm:"primary_key;autoIncrement"`
	BucketID        uint64 `gorm:"index:bucket_to_read_record"`
	ObjectID        uint64 `gorm:"index:object_to_read_record"`
	UserAddress     string `gorm:"index:user_to_read_record"`
	ReadTimestampUs int64  `gorm:"index:time_to_read_record"` // microsecond timestamp
	BucketName      string
	ObjectName      string
	ReadSize        uint64
}

ReadRecordTable table schema

func (ReadRecordTable) TableName

func (ReadRecordTable) TableName() string

TableName is used to set ReadRecord Schema's table name in database

type RecoverFailedObjectTable added in v1.3.0

type RecoverFailedObjectTable struct {
	ObjectID        uint64 `gorm:"primary_key"`
	VirtualGroupID  uint32 `gorm:"index:idx_gvg"`
	RedundancyIndex int32
	Retry           int `gorm:"index:retry"`
}

func (RecoverFailedObjectTable) TableName added in v1.3.0

func (RecoverFailedObjectTable) TableName() string

type RecoverGVGStatsTable added in v1.3.0

type RecoverGVGStatsTable struct {
	VirtualGroupID       uint32 `gorm:"primary_key"`
	VirtualGroupFamilyID uint32
	RedundancyIndex      int32 `gorm:"index:redundancy_index"`
	StartAfter           uint64
	NextStartAfter       uint64
	Limit                uint32
	Status               int
	ObjectCount          uint64
}

func (RecoverGVGStatsTable) TableName added in v1.3.0

func (RecoverGVGStatsTable) TableName() string

type ReplicateFailedTable added in v0.2.3

type ReplicateFailedTable struct {
	ID         uint64 `gorm:"primary_key;autoIncrement"`
	UpdateTime string `gorm:"index:update_time_index"`
	ObjectID   uint64 `gorm:"index:object_id_index"`
	Bucket     string `gorm:"index:bucket_index"`
	Object     string `gorm:"index:object_index"`
	Error      string
	Logs       string
}

ReplicateFailedTable table schema.

func (ReplicateFailedTable) TableName added in v0.2.3

func (ReplicateFailedTable) TableName() string

TableName is used to set ReplicateTimeoutTable Schema's table name in database.

type ReplicateTimeoutTable added in v0.2.3

type ReplicateTimeoutTable struct {
	ID         uint64 `gorm:"primary_key;autoIncrement"`
	UpdateTime string `gorm:"index:update_time_index"`
	ObjectID   uint64 `gorm:"index:object_id_index"`
	Bucket     string `gorm:"index:bucket_index"`
	Object     string `gorm:"index:object_index"`
	Error      string
	Logs       string
}

ReplicateTimeoutTable table schema.

func (ReplicateTimeoutTable) TableName added in v0.2.3

func (ReplicateTimeoutTable) TableName() string

TableName is used to set ReplicateTimeoutTable Schema's table name in database.

type SealFailedTable added in v0.2.3

type SealFailedTable struct {
	ID         uint64 `gorm:"primary_key;autoIncrement"`
	UpdateTime string `gorm:"index:update_time_index"`
	ObjectID   uint64 `gorm:"index:object_id_index"`
	Bucket     string `gorm:"index:bucket_index"`
	Object     string `gorm:"index:object_index"`
	Error      string
	Logs       string
}

SealFailedTable table schema.

func (SealFailedTable) TableName added in v0.2.3

func (SealFailedTable) TableName() string

TableName is used to set SealTimeoutTable Schema's table name in database.

type SealTimeoutTable added in v0.2.3

type SealTimeoutTable struct {
	ID         uint64 `gorm:"primary_key;autoIncrement"`
	UpdateTime string `gorm:"index:update_time_index"`
	ObjectID   uint64 `gorm:"index:object_id_index"`
	Bucket     string `gorm:"index:bucket_index"`
	Object     string `gorm:"index:object_index"`
	Error      string
	Logs       string
}

SealTimeoutTable table schema.

func (SealTimeoutTable) TableName added in v0.2.3

func (SealTimeoutTable) TableName() string

TableName is used to set SealTimeoutTable Schema's table name in database.

type ShadowIntegrityMetaTable added in v1.5.0

type ShadowIntegrityMetaTable struct {
	ObjectID          uint64 `gorm:"primary_key"`
	RedundancyIndex   int32  `gorm:"primary_key"`
	IntegrityChecksum string
	PieceChecksumList string
	Version           int64
	ObjectSize        uint64
}

ShadowIntegrityMetaTable table schema

func (ShadowIntegrityMetaTable) TableName added in v1.5.0

func (ShadowIntegrityMetaTable) TableName() string

TableName is used to set ShadowIntegrityMetaTable schema's table name in database

type SpDBImpl

type SpDBImpl struct {
	// contains filtered or unexported fields
}

SpDBImpl storage provider database, implements SPDB interface

func NewSpDB

func NewSpDB(config *config.SQLDBConfig) (*SpDBImpl, error)

NewSpDB return a database instance

func (*SpDBImpl) BatchGetRecoverGVGStats added in v1.3.0

func (s *SpDBImpl) BatchGetRecoverGVGStats(gvgIDs []uint32) ([]*spdb.RecoverGVGStats, error)

func (*SpDBImpl) CheckQuotaAndAddReadRecord

func (s *SpDBImpl) CheckQuotaAndAddReadRecord(record *corespdb.ReadRecord, quota *corespdb.BucketQuota) (err error)

CheckQuotaAndAddReadRecord check current quota, and add read record

func (*SpDBImpl) ClearExpiredOffChainAuthKeys added in v1.6.0

func (s *SpDBImpl) ClearExpiredOffChainAuthKeys() error

ClearExpiredOffChainAuthKeys will clear those expired off chain auth keys from OffChainAuthKeyV2Table

func (*SpDBImpl) CountRecoverFailedObject added in v1.3.0

func (s *SpDBImpl) CountRecoverFailedObject() (count int64, err error)

func (*SpDBImpl) DeleteAllReplicatePieceChecksum added in v0.2.2

func (s *SpDBImpl) DeleteAllReplicatePieceChecksum(objectID uint64, redundancyIdx int32, pieceCount uint32) error

DeleteAllReplicatePieceChecksum deletes all the piece checksum.

func (*SpDBImpl) DeleteAllReplicatePieceChecksumOptimized added in v0.2.5

func (s *SpDBImpl) DeleteAllReplicatePieceChecksumOptimized(objectID uint64, redundancyIdx int32) (err error)

DeleteAllReplicatePieceChecksumOptimized deletes all piece checksums for a given objectID and redundancy_index.

func (*SpDBImpl) DeleteAuthKeysV2 added in v1.6.0

func (s *SpDBImpl) DeleteAuthKeysV2(userAddress string, domain string, publicKeys []string) (bool, error)

DeleteAuthKeysV2 delete user public keys

func (*SpDBImpl) DeleteExpiredBucketTraffic added in v1.2.0

func (s *SpDBImpl) DeleteExpiredBucketTraffic(yearMonth string) (err error)

DeleteExpiredBucketTraffic update the bucket traffic in traffic db with the new traffic

func (*SpDBImpl) DeleteExpiredReadRecord added in v1.2.0

func (s *SpDBImpl) DeleteExpiredReadRecord(ts, limit uint64) (err error)

DeleteExpiredReadRecord delete all read record before ts(ts is UnixMicro)

func (*SpDBImpl) DeleteGCObjectProgress added in v0.2.2

func (s *SpDBImpl) DeleteGCObjectProgress(taskKey string) error

DeleteGCObjectProgress is used to delete gc object task.

func (*SpDBImpl) DeleteMigrateBucket added in v1.3.0

func (s *SpDBImpl) DeleteMigrateBucket(bucketID uint64) error

func (*SpDBImpl) DeleteMigrateGVGUnit added in v0.2.3

func (s *SpDBImpl) DeleteMigrateGVGUnit(meta *spdb.MigrateGVGUnitMeta) error

func (*SpDBImpl) DeleteMigrateGVGUnitsByBucketID added in v0.2.4

func (s *SpDBImpl) DeleteMigrateGVGUnitsByBucketID(bucketID uint64) error

func (*SpDBImpl) DeleteObjectIntegrity added in v0.2.2

func (s *SpDBImpl) DeleteObjectIntegrity(objectID uint64, redundancyIndex int32) (err error)

DeleteObjectIntegrity deletes integrity meta info.

func (*SpDBImpl) DeleteRecoverFailedObject added in v1.3.0

func (s *SpDBImpl) DeleteRecoverFailedObject(objectID uint64) (err error)

func (*SpDBImpl) DeleteRecoverGVGStats added in v1.3.0

func (s *SpDBImpl) DeleteRecoverGVGStats(gvgID uint32) (err error)

func (*SpDBImpl) DeleteReplicatePieceChecksum added in v0.2.2

func (s *SpDBImpl) DeleteReplicatePieceChecksum(objectID uint64, segmentIdx uint32, redundancyIdx int32) (err error)

DeleteReplicatePieceChecksum deletes piece checksum.

func (*SpDBImpl) DeleteReplicatePieceChecksumsByObjectID added in v1.6.0

func (s *SpDBImpl) DeleteReplicatePieceChecksumsByObjectID(objectID uint64) (err error)

DeleteReplicatePieceChecksumsByObjectID deletes all piece checksums for a given objectID.

func (*SpDBImpl) DeleteShadowObjectIntegrity added in v1.5.0

func (s *SpDBImpl) DeleteShadowObjectIntegrity(objectID uint64, redundancyIndex int32) (err error)

func (*SpDBImpl) DeleteUploadProgress added in v0.2.2

func (s *SpDBImpl) DeleteUploadProgress(objectID uint64) error

func (*SpDBImpl) FetchAllSp

func (s *SpDBImpl) FetchAllSp(status ...sptypes.Status) ([]*sptypes.StorageProvider, error)

FetchAllSp get all sp info

func (*SpDBImpl) FetchAllSpWithoutOwnSp

func (s *SpDBImpl) FetchAllSpWithoutOwnSp(status ...sptypes.Status) ([]*sptypes.StorageProvider, error)

FetchAllSpWithoutOwnSp get all spp info without own sp info, own sp is identified by is_own field in db

func (*SpDBImpl) GetAllReplicatePieceChecksum added in v0.2.2

func (s *SpDBImpl) GetAllReplicatePieceChecksum(objectID uint64, redundancyIdx int32, pieceCount uint32) ([][]byte, error)

GetAllReplicatePieceChecksum gets all the piece checksums.

func (*SpDBImpl) GetAllReplicatePieceChecksumOptimized added in v0.2.5

func (s *SpDBImpl) GetAllReplicatePieceChecksumOptimized(objectID uint64, redundancyIdx int32, pieceCount uint32) ([][]byte, error)

GetAllReplicatePieceChecksumOptimized gets all replicate piece checksums for a given objectID and redundancyIdx.

func (*SpDBImpl) GetAuthKey added in v0.1.2

func (s *SpDBImpl) GetAuthKey(userAddress string, domain string) (*corespdb.OffChainAuthKey, error)

GetAuthKey get OffChainAuthKey from OffChainAuthKeyTable

func (*SpDBImpl) GetAuthKeyV2 added in v1.6.0

func (s *SpDBImpl) GetAuthKeyV2(userAddress string, domain string, publicKey string) (*corespdb.OffChainAuthKeyV2, error)

GetAuthKeyV2 get OffChainAuthKeyV2 from OffChainAuthKeyV2Table

func (*SpDBImpl) GetBucketReadRecord

func (s *SpDBImpl) GetBucketReadRecord(bucketID uint64, timeRange *corespdb.TrafficTimeRange) (records []*corespdb.ReadRecord, err error)

GetBucketReadRecord return bucket record list by time range

func (*SpDBImpl) GetBucketTraffic

func (s *SpDBImpl) GetBucketTraffic(bucketID uint64, yearMonth string) (traffic *corespdb.BucketTraffic, err error)

GetBucketTraffic return bucket traffic info by the year and month info year_month is the query bucket quota's month, like "2023-03"

func (*SpDBImpl) GetBucketTrafficCount added in v1.6.0

func (s *SpDBImpl) GetBucketTrafficCount(yearMonth string) (count int64, err error)

func (*SpDBImpl) GetGCMetasToGC added in v0.2.2

func (s *SpDBImpl) GetGCMetasToGC(limit int) ([]*spdb.GCObjectMeta, error)

func (*SpDBImpl) GetLatestBucketTraffic added in v1.1.0

func (s *SpDBImpl) GetLatestBucketTraffic(bucketID uint64) (traffic *corespdb.BucketTraffic, err error)

GetLatestBucketTraffic return the latest bucket traffic info of the bucket

func (*SpDBImpl) GetObjectIntegrity

func (s *SpDBImpl) GetObjectIntegrity(objectID uint64, redundancyIndex int32) (meta *corespdb.IntegrityMeta, err error)

GetObjectIntegrity returns the integrity hash info

func (*SpDBImpl) GetObjectReadRecord

func (s *SpDBImpl) GetObjectReadRecord(objectID uint64, timeRange *corespdb.TrafficTimeRange) (records []*corespdb.ReadRecord, err error)

GetObjectReadRecord return object record list by time range

func (*SpDBImpl) GetOwnSpInfo

func (s *SpDBImpl) GetOwnSpInfo() (*sptypes.StorageProvider, error)

GetOwnSpInfo query own sp info in db

func (*SpDBImpl) GetReadRecord

func (s *SpDBImpl) GetReadRecord(timeRange *corespdb.TrafficTimeRange) (records []*corespdb.ReadRecord, err error)

GetReadRecord return record list by time range

func (*SpDBImpl) GetRecoverFailedObject added in v1.3.0

func (s *SpDBImpl) GetRecoverFailedObject(objectID uint64) (*spdb.RecoverFailedObject, error)

func (*SpDBImpl) GetRecoverFailedObjects added in v1.3.0

func (s *SpDBImpl) GetRecoverFailedObjects(retry, limit uint32) ([]*spdb.RecoverFailedObject, error)

func (*SpDBImpl) GetRecoverFailedObjectsByRetryTime added in v1.3.0

func (s *SpDBImpl) GetRecoverFailedObjectsByRetryTime(retry uint32) ([]*spdb.RecoverFailedObject, error)

func (*SpDBImpl) GetRecoverGVGStats added in v1.3.0

func (s *SpDBImpl) GetRecoverGVGStats(gvgID uint32) (*spdb.RecoverGVGStats, error)

func (*SpDBImpl) GetReplicatePieceChecksum added in v0.2.2

func (s *SpDBImpl) GetReplicatePieceChecksum(objectID uint64, segmentIdx uint32, redundancyIdx int32) ([]byte, error)

GetReplicatePieceChecksum gets replicate piece checksum.

func (*SpDBImpl) GetShadowObjectIntegrity added in v1.5.0

func (s *SpDBImpl) GetShadowObjectIntegrity(objectID uint64, redundancyIndex int32) (meta *corespdb.ShadowIntegrityMeta, err error)

GetShadowObjectIntegrity returns the integrity hash info

func (*SpDBImpl) GetSpByAddress

func (s *SpDBImpl) GetSpByAddress(address string, addressType corespdb.SpAddressType) (*sptypes.StorageProvider, error)

GetSpByAddress query sp info in db by address and address type

func (*SpDBImpl) GetSpByEndpoint

func (s *SpDBImpl) GetSpByEndpoint(endpoint string) (*sptypes.StorageProvider, error)

GetSpByEndpoint query sp info by endpoint

func (*SpDBImpl) GetSpByID added in v0.2.4

func (s *SpDBImpl) GetSpByID(id uint32) (*sptypes.StorageProvider, error)

GetSpById query sp info by id

func (*SpDBImpl) GetUploadMetasToRejectUnsealByRangeTS added in v1.2.0

func (s *SpDBImpl) GetUploadMetasToRejectUnsealByRangeTS(limit int, startTS int64, endTS int64) ([]*corespdb.UploadObjectMeta, error)

func (*SpDBImpl) GetUploadMetasToReplicate added in v0.2.2

func (s *SpDBImpl) GetUploadMetasToReplicate(limit int, timeoutSecond int64) ([]*corespdb.UploadObjectMeta, error)

func (*SpDBImpl) GetUploadMetasToReplicateByStartTS added in v1.2.0

func (s *SpDBImpl) GetUploadMetasToReplicateByStartTS(limit int, startTS int64) ([]*corespdb.UploadObjectMeta, error)

func (*SpDBImpl) GetUploadMetasToSeal added in v0.2.2

func (s *SpDBImpl) GetUploadMetasToSeal(limit int, timeoutSecond int64) ([]*corespdb.UploadObjectMeta, error)

func (*SpDBImpl) GetUploadMetasToSealByStartTS added in v1.2.0

func (s *SpDBImpl) GetUploadMetasToSealByStartTS(limit int, startTS int64) ([]*corespdb.UploadObjectMeta, error)

func (*SpDBImpl) GetUploadState added in v0.2.2

func (s *SpDBImpl) GetUploadState(objectID uint64) (storetypes.TaskState, string, error)

func (*SpDBImpl) GetUserReadRecord

func (s *SpDBImpl) GetUserReadRecord(userAddress string, timeRange *corespdb.TrafficTimeRange) (records []*corespdb.ReadRecord, err error)

GetUserReadRecord return user record list by time range

func (*SpDBImpl) InitBucketTraffic added in v0.2.3

func (s *SpDBImpl) InitBucketTraffic(record *corespdb.ReadRecord, quota *corespdb.BucketQuota) error

InitBucketTraffic init the bucket traffic table

func (*SpDBImpl) InsertAuthKey added in v0.1.2

func (s *SpDBImpl) InsertAuthKey(newRecord *corespdb.OffChainAuthKey) error

InsertAuthKey insert a new record into OffChainAuthKeyTable

func (*SpDBImpl) InsertAuthKeyV2 added in v1.6.0

func (s *SpDBImpl) InsertAuthKeyV2(newRecord *corespdb.OffChainAuthKeyV2) error

InsertAuthKeyV2 insert a new record into OffChainAuthKeyV2

func (*SpDBImpl) InsertGCObjectProgress added in v0.2.2

func (s *SpDBImpl) InsertGCObjectProgress(gcMeta *spdb.GCObjectMeta) error

InsertGCObjectProgress is used to insert gc object progress.

func (*SpDBImpl) InsertMigrateGVGUnit added in v0.2.3

func (s *SpDBImpl) InsertMigrateGVGUnit(meta *spdb.MigrateGVGUnitMeta) error

func (*SpDBImpl) InsertPutEvent added in v0.2.3

func (s *SpDBImpl) InsertPutEvent(task coretask.Task) error

func (*SpDBImpl) InsertRecoverFailedObject added in v1.3.0

func (s *SpDBImpl) InsertRecoverFailedObject(object *spdb.RecoverFailedObject) error

func (*SpDBImpl) InsertReplicateEvent added in v0.2.3

func (s *SpDBImpl) InsertReplicateEvent(task coretask.ReplicatePieceTask) error

func (*SpDBImpl) InsertSealEvent added in v0.2.3

func (s *SpDBImpl) InsertSealEvent(task coretask.SealObjectTask) error

func (*SpDBImpl) InsertSwapOutUnit added in v0.2.3

func (s *SpDBImpl) InsertSwapOutUnit(meta *spdb.SwapOutMeta) error

func (*SpDBImpl) InsertUploadEvent added in v0.2.2

func (s *SpDBImpl) InsertUploadEvent(task coretask.UploadObjectTask) error

func (*SpDBImpl) InsertUploadProgress added in v0.2.2

func (s *SpDBImpl) InsertUploadProgress(objectID uint64, isAgentUpload bool) error

func (*SpDBImpl) ListAuthKeysV2 added in v1.6.0

func (s *SpDBImpl) ListAuthKeysV2(userAddress string, domain string) ([]string, error)

ListAuthKeysV2 list user public keys

func (*SpDBImpl) ListBucketMigrationToConfirm added in v1.3.0

func (s *SpDBImpl) ListBucketMigrationToConfirm(migrationStates []int) ([]*spdb.MigrateBucketProgressMeta, error)

func (*SpDBImpl) ListBucketTraffic added in v1.6.0

func (s *SpDBImpl) ListBucketTraffic(yearMonth string, offset, limit int) (traffics []*corespdb.BucketTraffic, err error)

ListBucketTraffic return bucket traffic info by the year and month info year_month is the query bucket quota's month, like "2023-03" Support paging query

func (*SpDBImpl) ListDestSPSwapOutUnits added in v0.2.3

func (s *SpDBImpl) ListDestSPSwapOutUnits() ([]*spdb.SwapOutMeta, error)

func (*SpDBImpl) ListIntegrityMetaByObjectIDRange added in v1.2.0

func (s *SpDBImpl) ListIntegrityMetaByObjectIDRange(startObjectID int64, endObjectID int64, includePrivate bool) ([]*corespdb.IntegrityMeta, error)

ListIntegrityMetaByObjectIDRange list integrity meta by a block number range

func (*SpDBImpl) ListMigrateGVGUnitsByBucketID added in v0.2.3

func (s *SpDBImpl) ListMigrateGVGUnitsByBucketID(bucketID uint64) ([]*spdb.MigrateGVGUnitMeta, error)

func (*SpDBImpl) ListReplicatePieceChecksumByObjectIDRange added in v1.2.0

func (s *SpDBImpl) ListReplicatePieceChecksumByObjectIDRange(startObjectID int64, endObjectID int64) ([]*corespdb.GCPieceMeta, error)

ListReplicatePieceChecksumByObjectIDRange gets all replicate piece checksums for a given objectID and redundancyIdx.

func (*SpDBImpl) ListShadowIntegrityMeta added in v1.5.0

func (s *SpDBImpl) ListShadowIntegrityMeta() ([]*corespdb.ShadowIntegrityMeta, error)

func (*SpDBImpl) QueryBucketMigrateSubscribeProgress added in v0.2.3

func (s *SpDBImpl) QueryBucketMigrateSubscribeProgress() (uint64, error)

func (*SpDBImpl) QueryMigrateBucketProgress added in v1.3.0

func (s *SpDBImpl) QueryMigrateBucketProgress(bucketID uint64) (*spdb.MigrateBucketProgressMeta, error)

func (*SpDBImpl) QueryMigrateBucketState added in v1.3.0

func (s *SpDBImpl) QueryMigrateBucketState(bucketID uint64) (int, error)

func (*SpDBImpl) QueryMigrateGVGUnit added in v0.2.3

func (s *SpDBImpl) QueryMigrateGVGUnit(migrateKey string) (*spdb.MigrateGVGUnitMeta, error)

func (*SpDBImpl) QuerySPExitSubscribeProgress added in v0.2.3

func (s *SpDBImpl) QuerySPExitSubscribeProgress() (uint64, error)

func (*SpDBImpl) QuerySwapOutSubscribeProgress added in v0.2.3

func (s *SpDBImpl) QuerySwapOutSubscribeProgress() (uint64, error)

func (*SpDBImpl) QuerySwapOutUnitInSrcSP added in v0.2.3

func (s *SpDBImpl) QuerySwapOutUnitInSrcSP(swapOutKey string) (*spdb.SwapOutMeta, error)

func (*SpDBImpl) RegisterStdDBStats added in v1.1.0

func (s *SpDBImpl) RegisterStdDBStats() (prometheus.Collector, error)

RegisterStdDBStats registers std lib sql DB

func (*SpDBImpl) SetObjectIntegrity

func (s *SpDBImpl) SetObjectIntegrity(meta *corespdb.IntegrityMeta) (err error)

SetObjectIntegrity puts(overwrites) integrity hash info to db

func (*SpDBImpl) SetOwnSpInfo

func (s *SpDBImpl) SetOwnSpInfo(sp *sptypes.StorageProvider) error

SetOwnSpInfo set(maybe overwrite) own sp info to db

func (*SpDBImpl) SetRecoverGVGStats added in v1.3.0

func (s *SpDBImpl) SetRecoverGVGStats(stats []*spdb.RecoverGVGStats) error

func (*SpDBImpl) SetReplicatePieceChecksum added in v0.2.2

func (s *SpDBImpl) SetReplicatePieceChecksum(objectID uint64, segmentIdx uint32, redundancyIdx int32, checksum []byte, version int64) error

SetReplicatePieceChecksum sets replicate checksum.

func (*SpDBImpl) SetShadowObjectIntegrity added in v1.5.0

func (s *SpDBImpl) SetShadowObjectIntegrity(meta *corespdb.ShadowIntegrityMeta) (err error)

SetShadowObjectIntegrity puts(overwrites) integrity hash info to db

func (*SpDBImpl) UpdateAllSp

func (s *SpDBImpl) UpdateAllSp(spList []*sptypes.StorageProvider) error

UpdateAllSp update(maybe overwrite) all sp info in db

func (*SpDBImpl) UpdateAuthKey added in v0.1.2

func (s *SpDBImpl) UpdateAuthKey(userAddress string, domain string, oldNonce int32, newNonce int32, newPublicKey string, newExpiryDate time.Time) error

UpdateAuthKey update OffChainAuthKey from OffChainAuthKeyTable

func (*SpDBImpl) UpdateBucketMigrateGCSubscribeProgress added in v1.3.0

func (s *SpDBImpl) UpdateBucketMigrateGCSubscribeProgress(blockHeight uint64) error

func (*SpDBImpl) UpdateBucketMigrateSubscribeProgress added in v0.2.3

func (s *SpDBImpl) UpdateBucketMigrateSubscribeProgress(blockHeight uint64) error

func (*SpDBImpl) UpdateBucketMigrationGCProgress added in v1.3.0

func (s *SpDBImpl) UpdateBucketMigrationGCProgress(progressMeta spdb.MigrateBucketProgressMeta) error

func (*SpDBImpl) UpdateBucketMigrationMigratingProgress added in v1.3.0

func (s *SpDBImpl) UpdateBucketMigrationMigratingProgress(bucketID uint64, gvgUnits uint32, gvgUnitsFinished uint32) error

func (*SpDBImpl) UpdateBucketMigrationPreDeductedQuota added in v1.3.0

func (s *SpDBImpl) UpdateBucketMigrationPreDeductedQuota(bucketID uint64, deductedQuota uint64, state int) error

func (*SpDBImpl) UpdateBucketMigrationProgress added in v1.3.0

func (s *SpDBImpl) UpdateBucketMigrationProgress(bucketID uint64, migrateState int) error

func (*SpDBImpl) UpdateBucketMigrationRecoupQuota added in v1.3.0

func (s *SpDBImpl) UpdateBucketMigrationRecoupQuota(bucketID uint64, recoupQuota uint64, state int) error

func (*SpDBImpl) UpdateBucketTraffic added in v1.1.0

func (s *SpDBImpl) UpdateBucketTraffic(bucketID uint64, update *corespdb.BucketTraffic) (err error)

UpdateBucketTraffic update the bucket traffic in traffic db with the new traffic

func (*SpDBImpl) UpdateExtraQuota added in v0.2.5

func (s *SpDBImpl) UpdateExtraQuota(bucketID, extraQuota uint64, yearMonth string) error

UpdateExtraQuota update the read consumed quota and free consumed quota in traffic db with the extra quota

func (*SpDBImpl) UpdateGCObjectProgress added in v0.2.2

func (s *SpDBImpl) UpdateGCObjectProgress(gcMeta *spdb.GCObjectMeta) error

func (*SpDBImpl) UpdateIntegrityChecksum added in v0.2.3

func (s *SpDBImpl) UpdateIntegrityChecksum(meta *corespdb.IntegrityMeta) (err error)

UpdateIntegrityChecksum update integrity hash info to db, TODO: if not exit, whether create it

func (*SpDBImpl) UpdateIntegrityMeta added in v1.5.0

func (s *SpDBImpl) UpdateIntegrityMeta(meta *corespdb.IntegrityMeta) (err error)

UpdateIntegrityMeta update both IntegrityChecksum and PieceChecksumList

func (*SpDBImpl) UpdateMigrateGVGMigratedBytesSize added in v1.3.0

func (s *SpDBImpl) UpdateMigrateGVGMigratedBytesSize(migrateKey string, migrateBytes uint64) error

func (*SpDBImpl) UpdateMigrateGVGRetryCount added in v1.1.0

func (s *SpDBImpl) UpdateMigrateGVGRetryCount(migrateKey string, retryTime int) error

func (*SpDBImpl) UpdateMigrateGVGUnitLastMigrateObjectID added in v0.2.3

func (s *SpDBImpl) UpdateMigrateGVGUnitLastMigrateObjectID(migrateKey string, lastMigratedObjectID uint64) error

func (*SpDBImpl) UpdateMigrateGVGUnitStatus added in v0.2.3

func (s *SpDBImpl) UpdateMigrateGVGUnitStatus(migrateKey string, migrateStatus int) error

func (*SpDBImpl) UpdatePieceChecksum added in v0.2.3

func (s *SpDBImpl) UpdatePieceChecksum(objectID uint64, redundancyIndex int32, checksum []byte, dataLength uint64) (err error)

UpdatePieceChecksum 1) If the IntegrityMetaTable does not exist, it will be created. 2) If the IntegrityMetaTable already exists, it will be appended to the existing PieceChecksumList.

func (*SpDBImpl) UpdateRecoverFailedObject added in v1.3.0

func (s *SpDBImpl) UpdateRecoverFailedObject(object *spdb.RecoverFailedObject) (err error)

func (*SpDBImpl) UpdateRecoverGVGStats added in v1.3.0

func (s *SpDBImpl) UpdateRecoverGVGStats(stats *spdb.RecoverGVGStats) (err error)

func (*SpDBImpl) UpdateSPExitSubscribeProgress added in v0.2.3

func (s *SpDBImpl) UpdateSPExitSubscribeProgress(blockHeight uint64) error

UpdateSPExitSubscribeProgress is used to update progress. insert a new one if it is not found in db.

func (*SpDBImpl) UpdateShadowIntegrityChecksum added in v1.5.0

func (s *SpDBImpl) UpdateShadowIntegrityChecksum(meta *corespdb.ShadowIntegrityMeta) (err error)

func (*SpDBImpl) UpdateShadowPieceChecksum added in v1.5.0

func (s *SpDBImpl) UpdateShadowPieceChecksum(objectID uint64, redundancyIndex int32, checksum []byte, version int64, dataLength uint64) (err error)

UpdateShadowPieceChecksum 1) If the ShadowIntegrityMetaTable does not exist, it will be created. 2) If the ShadowIntegrityMetaTable already exists, it will be appended to the existing PieceChecksumList.

func (*SpDBImpl) UpdateSwapOutSubscribeProgress added in v0.2.3

func (s *SpDBImpl) UpdateSwapOutSubscribeProgress(blockHeight uint64) error

func (*SpDBImpl) UpdateSwapOutUnitCompletedGVGList added in v0.2.3

func (s *SpDBImpl) UpdateSwapOutUnitCompletedGVGList(swapOutKey string, completedGVGList []uint32) error

func (*SpDBImpl) UpdateUploadProgress added in v0.2.2

func (s *SpDBImpl) UpdateUploadProgress(uploadMeta *corespdb.UploadObjectMeta) error

type SpInfoTable

type SpInfoTable struct {
	OperatorAddress string `gorm:"primary_key"`
	IsOwn           bool   `gorm:"primary_key"`
	ID              uint32
	FundingAddress  string
	SealAddress     string
	ApprovalAddress string
	TotalDeposit    string
	Status          int32
	Endpoint        string
	Moniker         string
	Identity        string
	Website         string
	SecurityContact string
	Details         string
}

SpInfoTable table schema

func (SpInfoTable) TableName

func (SpInfoTable) TableName() string

TableName is used to set SpInfoTable Schema's table name in database

type SwapOutTable added in v0.2.3

type SwapOutTable struct {
	SwapOutKey       string `gorm:"primary_key"`
	IsDestSP         bool   `gorm:"primary_key"`
	SwapOutMsg       string
	CompletedGVGList string
}

SwapOutTable table schema.

func (SwapOutTable) TableName added in v0.2.3

func (SwapOutTable) TableName() string

type UploadFailedTable added in v0.2.3

type UploadFailedTable struct {
	ID         uint64 `gorm:"primary_key;autoIncrement"`
	UpdateTime string `gorm:"index:update_time_index"`
	ObjectID   uint64 `gorm:"index:object_id_index"`
	Bucket     string `gorm:"index:bucket_index"`
	Object     string `gorm:"index:object_index"`
	Error      string
	Logs       string
}

UploadFailedTable table schema.

func (UploadFailedTable) TableName added in v0.2.3

func (UploadFailedTable) TableName() string

TableName is used to set UploadTimeoutTable Schema's table name in database.

type UploadObjectProgressTable added in v0.2.2

type UploadObjectProgressTable struct {
	ObjectID              uint64 `gorm:"primary_key"`
	TaskState             int32  `gorm:"index:state_index"`
	GlobalVirtualGroupID  uint32
	TaskStateDescription  string
	ErrorDescription      string
	SecondaryEndpoints    string
	SecondarySignatures   string
	CreateTimestampSecond int64 `gorm:"index:create_timestamp_index"`
	UpdateTimestampSecond int64 `gorm:"index:update_timestamp_index"`
	IsAgentUpload         bool
}

UploadObjectProgressTable table schema.

func (UploadObjectProgressTable) TableName added in v0.2.2

func (UploadObjectProgressTable) TableName() string

TableName is used to set UploadObjectProgressTable Schema's table name in database.

type UploadTimeoutTable added in v0.2.3

type UploadTimeoutTable struct {
	ID         uint64 `gorm:"primary_key;autoIncrement"`
	UpdateTime string `gorm:"index:update_time_index"`
	ObjectID   uint64 `gorm:"index:object_id_index"`
	Bucket     string `gorm:"index:bucket_index"`
	Object     string `gorm:"index:object_index"`
	Error      string
	Logs       string
}

UploadTimeoutTable table schema.

func (UploadTimeoutTable) TableName added in v0.2.3

func (UploadTimeoutTable) TableName() string

TableName is used to set UploadTimeoutTable Schema's table name in database.

Jump to

Keyboard shortcuts

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