Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BucketQuota ¶
type BucketQuota struct {
ReadQuotaSize uint64
}
BucketQuota defines read quota of a bucket
type BucketTraffic ¶
type BucketTraffic struct { BucketID uint64 YearMonth string // YearMonth is traffic's YearMonth, format "2023-02" BucketName string ReadConsumedSize uint64 ReadQuotaSize uint64 ModifyTime int64 }
BucketTraffic is record traffic by year and month
type GCObjectInfoDB ¶
type IntegrityMeta ¶
type IntegrityMeta struct { ObjectID uint64 IntegrityChecksum []byte PieceChecksumList [][]byte Signature []byte }
IntegrityMeta defines the payload integrity hash and piece checksum with objectID
type JobDB ¶
type JobDB interface { // CreateUploadJob create upload job and return job context CreateUploadJob(objectInfo *storagetypes.ObjectInfo) (*servicetypes.JobContext, error) // UpdateJobState update the state of a job by object id UpdateJobState(objectID uint64, state servicetypes.JobState) error // GetJobByID get job context by job id and return job context GetJobByID(jobID uint64) (*servicetypes.JobContext, error) // GetJobByObjectID get job context by object id GetJobByObjectID(objectID uint64) (*servicetypes.JobContext, error) }
JobDB interface which contains job related to object id interface
type ObjectDB ¶
type ObjectDB interface { // GetObjectInfo get object info by object id GetObjectInfo(objectID uint64) (*storagetypes.ObjectInfo, error) // SetObjectInfo set(maybe overwrite) object info by object id SetObjectInfo(objectID uint64, objectInfo *storagetypes.ObjectInfo) error }
ObjectDB interface which contains get and set object info interface
type ObjectIntegrityDB ¶
type ObjectIntegrityDB interface { // GetObjectIntegrity get integrity meta info by object id GetObjectIntegrity(objectID uint64) (*IntegrityMeta, error) // SetObjectIntegrity set(maybe overwrite) integrity hash info to db SetObjectIntegrity(integrity *IntegrityMeta) error DeleteObjectIntegrity(objectID uint64) error GetReplicatePieceChecksum(objectID uint64, replicateIdx uint32, pieceIdx uint32) ([]byte, error) SetReplicatePieceChecksum(objectID uint64, replicateIdx uint32, pieceIdx uint32, checksum []byte) error DeleteReplicatePieceChecksum(objectID uint64, replicateIdx uint32, pieceIdx uint32) error GetAllReplicatePieceChecksum(objectID uint64, replicateIdx uint32, pieceCount uint32) ([][]byte, error) SetAllReplicatePieceChecksum(objectID uint64, replicateIdx uint32, pieceCount uint32, checksum [][]byte) error DeleteAllReplicatePieceChecksum(objectID uint64, replicateIdx uint32, pieceCount uint32) error }
ObjectIntegrityDB abstract object integrity interface
type OffChainAuthKey ¶
type OffChainAuthKeyDB ¶
type OffChainAuthKeyDB interface { GetAuthKey(userAddress string, domain string) (*OffChainAuthKey, error) UpdateAuthKey(userAddress string, domain string, oldNonce int32, newNonce int32, newPublicKey string, newExpiryDate time.Time) error InsertAuthKey(newRecord *OffChainAuthKey) error }
OffChainAuthKeyDB interface
type ReadRecord ¶
type ReadRecord struct { BucketID uint64 ObjectID uint64 UserAddress string BucketName string ObjectName string ReadSize uint64 ReadTimestampUs int64 }
ReadRecord defines a read request record, will decrease the bucket read quota
type SPDB ¶
type SPDB interface { JobDB ObjectDB ObjectIntegrityDB TrafficDB SPInfoDB GCObjectInfoDB StorageParamDB OffChainAuthKeyDB }
type SPInfoDB ¶
type SPInfoDB interface { // UpdateAllSp update all sp info, delete old sp info UpdateAllSp(spList []*sptypes.StorageProvider) error // FetchAllSp if status is nil return all sp info; otherwise return sp info by status FetchAllSp(status ...sptypes.Status) ([]*sptypes.StorageProvider, error) // FetchAllSpWithoutOwnSp if status is nil return all sp info without own sp; // otherwise return sp info by status without own sp FetchAllSpWithoutOwnSp(status ...sptypes.Status) ([]*sptypes.StorageProvider, error) // GetSpByAddress return sp info by address and addressType GetSpByAddress(address string, addressType SpAddressType) (*sptypes.StorageProvider, error) // GetSpByEndpoint return sp info by endpoint GetSpByEndpoint(endpoint string) (*sptypes.StorageProvider, error) // GetOwnSpInfo return own sp info GetOwnSpInfo() (*sptypes.StorageProvider, error) // SetOwnSpInfo set(maybe overwrite) own sp info SetOwnSpInfo(sp *sptypes.StorageProvider) error }
type SpAddressType ¶
type SpAddressType int32
SpAddressType identify address type of SP
const ( OperatorAddressType SpAddressType = iota + 1 FundingAddressType SealAddressType ApprovalAddressType )
type StorageParamDB ¶
type StorageParamDB interface { // GetStorageParams return storage params GetStorageParams() (*storagetypes.Params, error) // SetStorageParams set(maybe overwrite) storage params SetStorageParams(params *storagetypes.Params) error }
StorageParamDB interface
type TrafficDB ¶
type TrafficDB interface { // CheckQuotaAndAddReadRecord create bucket traffic firstly if bucket is not existed, // and check whether the added traffic record exceeds the quota, if it exceeds the quota, // it will return error, Otherwise, add a record and return nil. CheckQuotaAndAddReadRecord(record *ReadRecord, quota *BucketQuota) error // GetBucketTraffic return bucket traffic info, // notice maybe return (nil, nil) while there is no bucket traffic GetBucketTraffic(bucketID uint64, yearMonth string) (*BucketTraffic, error) // GetReadRecord return record list by time range GetReadRecord(timeRange *TrafficTimeRange) ([]*ReadRecord, error) // GetBucketReadRecord return bucket record list by time range GetBucketReadRecord(bucketID uint64, timeRange *TrafficTimeRange) ([]*ReadRecord, error) // GetObjectReadRecord return object record list by time range GetObjectReadRecord(objectID uint64, timeRange *TrafficTimeRange) ([]*ReadRecord, error) // GetUserReadRecord return user record list by time range GetUserReadRecord(userAddress string, timeRange *TrafficTimeRange) ([]*ReadRecord, error) }
TrafficDB define a series of traffic interfaces
type TrafficTimeRange ¶
type TrafficTimeRange struct { StartTimestampUs int64 EndTimestampUs int64 LimitNum int // is unlimited if LimitNum <= 0 }
TrafficTimeRange is used by query, return records in [StartTimestampUs, EndTimestampUs)