Documentation ¶
Index ¶
- Constants
- Variables
- func GetCurrentTimestampUs() int64
- func GetCurrentUnixTime() int64
- func GetCurrentYearMonth() string
- func GetIntegrityMetasShardNumberByBucketName(objectID uint64) uint64
- func GetIntegrityMetasTableName(objectID uint64) string
- func GetIntegrityMetasTableNameByShardNumber(shard int) string
- func InitDB(config *config.SQLDBConfig) (*gorm.DB, error)
- func LoadDBConfigFromEnv(config *config.SQLDBConfig)
- func MysqlErrCode(err error) int
- func OverrideConfigVacancy(config *config.SQLDBConfig)
- func TimeToYearMonth(t time.Time) string
- func TimestampSecToTime(timeUnix int64) time.Time
- func TimestampUsToTime(ts int64) time.Time
- type Batch
- type Batcher
- type BucketTrafficTable
- type GCObjectProgressTable
- type IntegrityMetaTable
- type Iteratee
- type Iterator
- type OffChainAuthKeyTable
- type PieceHashTable
- type PutObjectEventTable
- type PutObjectSuccessTable
- type ReadRecordTable
- type ReplicateFailedTable
- type ReplicateTimeoutTable
- type SealFailedTable
- type SealTimeoutTable
- type SpDBImpl
- func (s *SpDBImpl) AppendObjectChecksumIntegrity(objectID uint64, checksum []byte) (err error)
- func (s *SpDBImpl) CheckQuotaAndAddReadRecord(record *corespdb.ReadRecord, quota *corespdb.BucketQuota) (err error)
- func (s *SpDBImpl) DeleteAllReplicatePieceChecksum(objectID uint64, replicateIdx uint32, pieceCount uint32) error
- func (s *SpDBImpl) DeleteGCObjectProgress(taskKey string) error
- func (s *SpDBImpl) DeleteObjectIntegrity(objectID uint64) (err error)
- func (s *SpDBImpl) DeleteReplicatePieceChecksum(objectID uint64, replicateIdx uint32, pieceIdx uint32) (err error)
- func (s *SpDBImpl) DeleteUploadProgress(objectID uint64) error
- func (s *SpDBImpl) FetchAllSp(status ...sptypes.Status) ([]*sptypes.StorageProvider, error)
- func (s *SpDBImpl) FetchAllSpWithoutOwnSp(status ...sptypes.Status) ([]*sptypes.StorageProvider, error)
- func (s *SpDBImpl) GetAllReplicatePieceChecksum(objectID uint64, replicateIdx uint32, pieceCount uint32) ([][]byte, error)
- func (s *SpDBImpl) GetAuthKey(userAddress string, domain string) (*corespdb.OffChainAuthKey, error)
- func (s *SpDBImpl) GetBucketReadRecord(bucketID uint64, timeRange *corespdb.TrafficTimeRange) (records []*corespdb.ReadRecord, err error)
- func (s *SpDBImpl) GetBucketTraffic(bucketID uint64, yearMonth string) (traffic *corespdb.BucketTraffic, err error)
- func (s *SpDBImpl) GetGCMetasToGC(limit int) ([]*spdb.GCObjectMeta, error)
- func (s *SpDBImpl) GetObjectIntegrity(objectID uint64) (meta *corespdb.IntegrityMeta, err error)
- func (s *SpDBImpl) GetObjectReadRecord(objectID uint64, timeRange *corespdb.TrafficTimeRange) (records []*corespdb.ReadRecord, err error)
- func (s *SpDBImpl) GetOwnSpInfo() (*sptypes.StorageProvider, error)
- func (s *SpDBImpl) GetReadRecord(timeRange *corespdb.TrafficTimeRange) (records []*corespdb.ReadRecord, err error)
- func (s *SpDBImpl) GetReplicatePieceChecksum(objectID uint64, replicateIdx uint32, pieceIdx uint32) ([]byte, error)
- func (s *SpDBImpl) GetSpByAddress(address string, addressType corespdb.SpAddressType) (*sptypes.StorageProvider, error)
- func (s *SpDBImpl) GetSpByEndpoint(endpoint string) (*sptypes.StorageProvider, error)
- func (s *SpDBImpl) GetUploadMetasToReplicate(limit int) ([]*corespdb.UploadObjectMeta, error)
- func (s *SpDBImpl) GetUploadMetasToSeal(limit int) ([]*corespdb.UploadObjectMeta, error)
- func (s *SpDBImpl) GetUploadState(objectID uint64) (storetypes.TaskState, error)
- func (s *SpDBImpl) GetUserReadRecord(userAddress string, timeRange *corespdb.TrafficTimeRange) (records []*corespdb.ReadRecord, err error)
- func (s *SpDBImpl) InsertAuthKey(newRecord *corespdb.OffChainAuthKey) error
- func (s *SpDBImpl) InsertGCObjectProgress(taskKey string, gcMeta *spdb.GCObjectMeta) error
- func (s *SpDBImpl) InsertPutEvent(task coretask.Task) error
- func (s *SpDBImpl) InsertReplicateEvent(task coretask.ReplicatePieceTask) error
- func (s *SpDBImpl) InsertSealEvent(task coretask.SealObjectTask) error
- func (s *SpDBImpl) InsertUploadEvent(task coretask.UploadObjectTask) error
- func (s *SpDBImpl) InsertUploadProgress(objectID uint64) error
- func (s *SpDBImpl) SetObjectIntegrity(meta *corespdb.IntegrityMeta) (err error)
- func (s *SpDBImpl) SetOwnSpInfo(sp *sptypes.StorageProvider) error
- func (s *SpDBImpl) SetReplicatePieceChecksum(objectID uint64, replicateIdx uint32, pieceIdx uint32, checksum []byte) error
- func (s *SpDBImpl) UpdateAllSp(spList []*sptypes.StorageProvider) error
- func (s *SpDBImpl) UpdateAuthKey(userAddress string, domain string, oldNonce int32, newNonce int32, ...) error
- func (s *SpDBImpl) UpdateGCObjectProgress(gcMeta *spdb.GCObjectMeta) error
- func (s *SpDBImpl) UpdateUploadProgress(uploadMeta *corespdb.UploadObjectMeta) error
- type SpInfoTable
- type UploadFailedTable
- type UploadObjectProgressTable
- type UploadTimeoutTable
Constants ¶
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" // 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" // 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" )
define table name constant.
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" // SPDBSuccessAppendObjectChecksumIntegrity defines the metrics label of successfully append object checksum integrity SPDBSuccessAppendObjectChecksumIntegrity = "append_object_checksum_integrity_success" // SPDBFailureAppendObjectChecksumIntegrity defines the metrics label of unsuccessfully append object checksum integrity SPDBFailureAppendObjectChecksumIntegrity = "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" )
const ( IntegrityMetasNumberOfShards = 64 ReasonableTableSize = 5_000_000 )
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 )
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" )
Variables ¶
var ( // ErrCheckQuotaEnough defines check quota is enough ErrCheckQuotaEnough = errors.New("quota is not enough") )
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
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 GetIntegrityMetasTableNameByShardNumber ¶ added in v0.2.3
func LoadDBConfigFromEnv ¶
func LoadDBConfigFromEnv(config *config.SQLDBConfig)
LoadDBConfigFromEnv load db user and password from env vars
func MysqlErrCode ¶ added in v0.2.2
func OverrideConfigVacancy ¶ added in v0.1.1
func OverrideConfigVacancy(config *config.SQLDBConfig)
OverrideConfigVacancy override the SQLDB param zero value
func TimeToYearMonth ¶
TimeToYearMonth convent time.Time to YYYY-MM string
func TimestampSecToTime ¶
TimestampSecToTime convert a second timestamp to time.Time
func TimestampUsToTime ¶
TimestampUsToTime convert a microsecond timestamp to time.Time
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 ReadQuotaSize uint64 // ReadQuotaSize = the greenfield chain bucket quota + the sp default 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 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"` IntegrityChecksum string PieceChecksumList string Signature string }
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 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 JobTable Schema's table name in database
type PieceHashTable ¶ added in v0.2.2
type PieceHashTable struct { ObjectID uint64 `gorm:"primary_key"` ReplicateIndex uint32 `gorm:"primary_key"` PieceIndex uint32 `gorm:"primary_key"` PieceChecksum string }
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 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 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) AppendObjectChecksumIntegrity ¶
AppendObjectChecksumIntegrity append checksum
func (*SpDBImpl) CheckQuotaAndAddReadRecord ¶
func (s *SpDBImpl) CheckQuotaAndAddReadRecord(record *corespdb.ReadRecord, quota *corespdb.BucketQuota) (err error)
CheckQuotaAndAddReadRecord check current quota, and add read record TODO: Traffic statistics may be inaccurate in extreme cases, optimize it in the future
func (*SpDBImpl) DeleteAllReplicatePieceChecksum ¶ added in v0.2.2
func (s *SpDBImpl) DeleteAllReplicatePieceChecksum(objectID uint64, replicateIdx uint32, pieceCount uint32) error
DeleteAllReplicatePieceChecksum deletes all the piece checksum.
func (*SpDBImpl) DeleteGCObjectProgress ¶ added in v0.2.2
DeleteGCObjectProgress is used to delete gc object task.
func (*SpDBImpl) DeleteObjectIntegrity ¶ added in v0.2.2
DeleteObjectIntegrity deletes integrity meta info.
func (*SpDBImpl) DeleteReplicatePieceChecksum ¶ added in v0.2.2
func (s *SpDBImpl) DeleteReplicatePieceChecksum(objectID uint64, replicateIdx uint32, pieceIdx uint32) (err error)
DeleteReplicatePieceChecksum deletes piece checksum.
func (*SpDBImpl) DeleteUploadProgress ¶ added in v0.2.2
func (*SpDBImpl) FetchAllSp ¶
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, replicateIdx uint32, pieceCount uint32) ([][]byte, error)
GetAllReplicatePieceChecksum gets all the piece checksums.
func (*SpDBImpl) GetAuthKey ¶ added in v0.1.2
GetAuthKey get OffChainAuthKey from OffChainAuthKeyTable
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
func (*SpDBImpl) GetGCMetasToGC ¶ added in v0.2.2
func (s *SpDBImpl) GetGCMetasToGC(limit int) ([]*spdb.GCObjectMeta, error)
func (*SpDBImpl) GetObjectIntegrity ¶
func (s *SpDBImpl) GetObjectIntegrity(objectID uint64) (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) GetReplicatePieceChecksum ¶ added in v0.2.2
func (s *SpDBImpl) GetReplicatePieceChecksum(objectID uint64, replicateIdx uint32, pieceIdx uint32) ([]byte, error)
GetReplicatePieceChecksum gets replicate piece checksum.
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) GetUploadMetasToReplicate ¶ added in v0.2.2
func (s *SpDBImpl) GetUploadMetasToReplicate(limit int) ([]*corespdb.UploadObjectMeta, error)
func (*SpDBImpl) GetUploadMetasToSeal ¶ added in v0.2.2
func (s *SpDBImpl) GetUploadMetasToSeal(limit int) ([]*corespdb.UploadObjectMeta, error)
func (*SpDBImpl) GetUploadState ¶ added in v0.2.2
func (s *SpDBImpl) GetUploadState(objectID uint64) (storetypes.TaskState, 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) InsertAuthKey ¶ added in v0.1.2
func (s *SpDBImpl) InsertAuthKey(newRecord *corespdb.OffChainAuthKey) error
InsertAuthKey insert a new record into OffChainAuthKeyTable
func (*SpDBImpl) InsertGCObjectProgress ¶ added in v0.2.2
func (s *SpDBImpl) InsertGCObjectProgress(taskKey string, gcMeta *spdb.GCObjectMeta) error
InsertGCObjectProgress is used to insert gc object progress.
func (*SpDBImpl) InsertPutEvent ¶ added in v0.2.3
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) InsertUploadEvent ¶ added in v0.2.2
func (s *SpDBImpl) InsertUploadEvent(task coretask.UploadObjectTask) error
func (*SpDBImpl) InsertUploadProgress ¶ added in v0.2.2
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) SetReplicatePieceChecksum ¶ added in v0.2.2
func (s *SpDBImpl) SetReplicatePieceChecksum(objectID uint64, replicateIdx uint32, pieceIdx uint32, checksum []byte) error
SetReplicatePieceChecksum sets replicate checksum.
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) UpdateGCObjectProgress ¶ added in v0.2.2
func (s *SpDBImpl) UpdateGCObjectProgress(gcMeta *spdb.GCObjectMeta) 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"` 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 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"` TaskStateDescription string ErrorDescription string SecondaryAddresses string SecondarySignatures string CreateTimestampSecond int64 UpdateTimestampSecond int64 `gorm:"index:update_timestamp_index"` }
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.
Source Files ¶
- batch.go
- const.go
- errors.go
- gc_object.go
- gc_object_schema.go
- iterator.go
- object_integrity.go
- object_integrity_schema.go
- off_chain_auth_key.go
- off_chain_auth_key_schema.go
- sp.go
- sp_schema.go
- store.go
- traffic.go
- traffic_schema.go
- upload_event.go
- upload_event_schema.go
- upload_object.go
- upload_object_schema.go
- util.go