chain

package
v0.0.26 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OSS is a module about DeOSS
	OSS = "Oss"
	// FILEBANK is a module about data metadata, bucket info, etc.
	FILEBANK = "FileBank"
	// TEEWOEKER is a module about TEE
	TEEWORKER = "TeeWorker"
	// SMINER is a module about storage miners
	SMINER = "Sminer"
	// SMINER is a module about storage miners
	STORAGEHANDLER = "StorageHandler"
	//
	NETSNAPSHOT = "NetSnapShotStorage"
	// SYSTEM is a module about the system
	SYSTEM = "System"
)

Pallets

View Source
const (
	// OSS
	// OSS
	AUTHORITYLIST = "AuthorityList"

	// SMINER
	ALLMINER   = "AllMiner"
	MINERITEMS = "MinerItems"

	// TEEWORKER
	SCHEDULERMAP = "SchedulerMap"

	// FILEBANK
	FILE           = "File"
	BUCKET         = "Bucket"
	BUCKETLIST     = "UserBucketList"
	DEALMAP        = "DealMap"
	PENDINGREPLACE = "PendingReplacements"

	// STORAGEHANDLER
	USERSPACEINFO = "UserOwnedSpace"
	UNITPRICE     = "UnitPrice"

	// NetSnapShotStorage
	NETSNAPSHOTSTORAGE = "NetSnapShotStorage"

	// SYSTEM
	ACCOUNT = "Account"
	EVENTS  = "Events"
)

Chain state

View Source
const (
	// OSS
	TX_OSS_REGISTER = OSS + DOT + "register"
	TX_OSS_UPDATE   = OSS + DOT + "update"
	TX_OSS_DESTORY  = OSS + DOT + "destroy"

	// SMINER
	TX_SMINER_REGISTER       = SMINER + DOT + "regnstk"
	TX_SMINER_EXIT           = SMINER + DOT + "exit_miner"
	TX_SMINER_INCREASESTAKES = SMINER + DOT + "increase_collateral"
	TX_SMINER_UPDATEADDR     = SMINER + DOT + "update_ip"
	TX_SMINER_UPDATEINCOME   = SMINER + DOT + "update_beneficiary"

	// FILEBANK
	TX_FILEBANK_PUTBUCKET    = FILEBANK + DOT + "create_bucket"
	TX_FILEBANK_DELBUCKET    = FILEBANK + DOT + "delete_bucket"
	TX_FILEBANK_DELFILE      = FILEBANK + DOT + "delete_file"
	TX_FILEBANK_UPLOADDEC    = FILEBANK + DOT + "upload_declaration"
	TX_FILEBANK_ADDIDLESPACE = FILEBANK + DOT + "test_add_idle_space"
	TX_FILEBANK_FILEREPORT   = FILEBANK + DOT + "transfer_report"
	TX_FILEBANK_REPLACEFILE  = FILEBANK + DOT + "replace_file_report"
)

Extrinsics

View Source
const (
	Role_OSS    = "OSS"
	Role_DEOSS  = "DEOSS"
	Role_BUCKET = "BUCKET"
)
View Source
const (
	Active = iota
	Calculate
	Missing
	Recovery
)
View Source
const (
	MINER_STATE_POSITIVE = "positive"
	MINER_STATE_FROZEN   = "frozen"
	MINER_STATE_EXIT     = "exit"
)
View Source
const (
	ERR_Failed  = "failed"
	ERR_Timeout = "timeout"
	ERR_Empty   = "empty"
)
View Source
const DOT = "."

DOT is "." character

View Source
const TokenPrecision_CESS = "000000000000"

Unit precision of CESS token

Variables

View Source
var (
	ERR_RPC_CONNECTION  = errors.New("rpc connection failed")
	ERR_RPC_IP_FORMAT   = errors.New("unsupported ip format")
	ERR_RPC_TIMEOUT     = errors.New("timeout")
	ERR_RPC_EMPTY_VALUE = errors.New("empty")
)

Functions

This section is empty.

Types

type BucketInfo

type BucketInfo struct {
	Objects_list []FileHash
	Authority    []types.AccountID
}

type CacherInfo

type CacherInfo struct {
	Acc       types.AccountID
	Ip        types.Bytes
	BytePrice types.U128
}

type Chain

type Chain interface {
	// Getpublickey returns its own public key
	GetPublicKey() []byte
	// Getpublickey returns its own private key
	GetMnemonicSeed() string
	// NewAccountId returns the account id
	NewAccountId(pubkey []byte) types.AccountID
	// GetSyncStatus returns whether the block is being synchronized
	GetSyncStatus() (bool, error)
	// GetChainStatus returns chain status
	GetChainStatus() bool
	// Getstorageminerinfo is used to get the details of the miner
	QueryStorageMiner(pkey []byte) (MinerInfo, error)
	//
	QueryDeoss(pubkey []byte) (string, error)
	// Getallstorageminer is used to obtain the AccountID of all miners
	GetAllStorageMiner() ([]types.AccountID, error)
	// GetFileMetaInfo is used to get the meta information of the file
	GetFileMetaInfo(fid string) (FileMetaInfo, error)
	// GetCessAccount is used to get the account in cess chain format
	GetCessAccount() (string, error)
	// GetAccountInfo is used to get account information
	GetAccountInfo(pkey []byte) (types.AccountInfo, error)
	//
	IsGrantor(pubkey []byte) (bool, error)

	// GetBucketList is used to obtain all buckets of the user
	GetBucketList(owner_pkey []byte) ([]types.Bytes, error)
	// GetBucketInfo is used to query bucket details
	GetBucketInfo(owner_pkey []byte, name string) (BucketInfo, error)
	// GetGrantor is used to query the user's space grantor
	GetGrantor(pkey []byte) (types.AccountID, error)
	// GetState is used to obtain OSS status information
	GetState(pubkey []byte) (string, error)
	// Register is used to register OSS or BUCKET roles
	Register(name, multiaddr string, income string, pledge uint64) (string, error)
	// Update is used to update the communication address of the scheduling service
	UpdateAddress(name, multiaddr string) (string, error)
	//
	UpdateIncomeAccount(pubkey []byte) (string, error)
	// CreateBucket is used to create a bucket for users
	CreateBucket(owner_pkey []byte, name string) (string, error)
	// DeleteBucket is used to delete buckets created by users
	DeleteBucket(owner_pkey []byte, name string) (string, error)
	//
	DeleteFile(owner_pkey []byte, filehash string) (string, FileHash, error)
	//
	UploadDeclaration(filehash string, dealinfo []SegmentList, user UserBrief) (string, error)
	//
	GetStorageOrder(roothash string) (StorageOrder, error)
	//
	SubmitIdleFile(idlefiles []IdleMetaInfo) (string, error)
	//
	SubmitFileReport(roothash []FileHash) (string, []FileHash, error)
	//
	ReplaceFile(roothash []FileHash) (string, []FileHash, error)
	//
	QueryPendingReplacements(owner_pkey []byte) (types.U32, error)
	//
	QueryUserSpaceInfo(pubkey []byte) (UserSpaceInfo, error)
	//
	IncreaseStakes(tokens *big.Int) (string, error)
	//
	Exit(role string) (string, error)
	//
	QuerySpacePricePerGib() (string, error)
	//
	QueryNetSnapShot() (NetSnapShot, error)
}

func NewChainClient

func NewChainClient(rpcAddr []string, secret string, t time.Duration) (Chain, error)

type EventRecords

type EventRecords struct {
	// AUDIT
	SegmentBook_PPBNoOnTimeSubmit     []Event_PPBNoOnTimeSubmit
	SegmentBook_PPDNoOnTimeSubmit     []Event_PPDNoOnTimeSubmit
	SegmentBook_ChallengeProof        []Event_ChallengeProof
	SegmentBook_VerifyProof           []Event_VerifyProof
	SegmentBook_OutstandingChallenges []Event_OutstandingChallenges
	// SMINER
	Sminer_Registered          []Event_Registered
	Sminer_TimedTask           []Event_TimedTask
	Sminer_DrawFaucetMoney     []Event_DrawFaucetMoney
	Sminer_FaucetTopUpMoney    []Event_FaucetTopUpMoney
	Sminer_LessThan24Hours     []Event_LessThan24Hours
	Sminer_AlreadyFrozen       []Event_AlreadyFrozen
	Sminer_MinerExit           []Event_MinerExit
	Sminer_MinerClaim          []Event_MinerClaim
	Sminer_IncreaseCollateral  []Event_IncreaseCollateral
	Sminer_Deposit             []Event_Deposit
	Sminer_Redeemed            []Event_Redeemed
	Sminer_Claimed             []Event_Claimed
	Sminer_TimingStorageSpace  []Event_TimingStorageSpace
	Sminer_UpdataBeneficiary   []Event_UpdataBeneficiary
	Sminer_UpdataIp            []Event_UpdataIp
	Sminer_StartOfBufferPeriod []Event_StartOfBufferPeriod
	Sminer_EndOfBufferPeriod   []Event_EndOfBufferPeriod
	// FILEBANK
	FileBank_DeleteFile        []Event_DeleteFile
	FileBank_FileUpload        []Event_FileUpload
	FileBank_FileUpdate        []Event_FileUpdate
	FileBank_FileChangeState   []Event_FileChangeState
	FileBank_BuyFile           []Event_BuyFile
	FileBank_Purchased         []Event_Purchased
	FileBank_InsertFileSlice   []Event_InsertFileSlice
	FileBank_FillerUpload      []Event_FillerUpload
	FileBank_ClearInvalidFile  []Event_ClearInvalidFile
	FileBank_RecoverFile       []Event_RecoverFile
	FileBank_ReceiveSpace      []Event_ReceiveSpace
	FileBank_UploadDeclaration []Event_UploadDeclaration
	FileBank_CreateBucket      []Event_CreateBucket
	FileBank_DeleteBucket      []Event_DeleteBucket
	FileBank_TransferReport    []Event_TransferReport
	FileBank_ReplaceFiller     []Event_ReplaceFiller
	FileBank_CalculateEnd      []Event_CalculateEnd
	// StorageHandler
	StorageHandler_BuySpace             []Event_BuySpace
	StorageHandler_ExpansionSpace       []Event_ExpansionSpace
	StorageHandler_RenewalSpace         []Event_RenewalSpace
	StorageHandler_LeaseExpired         []Event_LeaseExpired
	StorageHandler_LeaseExpireIn24Hours []Event_LeaseExpireIn24Hours
	// TeeWorker
	TeeWorker_RegistrationScheduler []Event_RegistrationScheduler
	TeeWorker_UpdateScheduler       []Event_UpdateScheduler
	// OSS
	Oss_OssRegister []Event_OssRegister
	Oss_OssUpdate   []Event_OssUpdate
	Oss_OssDestroy  []Event_OssDestroy
	// System
	types.EventRecords
}

Events

type Event_AlreadyFrozen

type Event_AlreadyFrozen struct {
	Phase  types.Phase
	Acc    types.AccountID
	Topics []types.Hash
}

type Event_Balances_Withdraw

type Event_Balances_Withdraw struct {
	Phase  types.Phase
	Who    types.AccountID
	Amount types.U128
	Topics []types.Hash
}

type Event_BuyFile

type Event_BuyFile struct {
	Phase  types.Phase
	Acc    types.AccountID
	Money  types.U128
	Fileid types.Bytes
	Topics []types.Hash
}

type Event_BuySpace

type Event_BuySpace struct {
	Phase            types.Phase
	Acc              types.AccountID
	Storage_capacity types.U128
	Spend            types.U128
	Topics           []types.Hash
}

------------------------StorageHandler--------------------------------

type Event_CalculateEnd added in v0.0.11

type Event_CalculateEnd struct {
	Phase     types.Phase
	File_hash FileHash
	Topics    []types.Hash
}

type Event_ChallengeProof

type Event_ChallengeProof struct {
	Phase  types.Phase
	Miner  types.AccountID
	Fileid types.Bytes
	Topics []types.Hash
}

type Event_Claimed

type Event_Claimed struct {
	Phase   types.Phase
	Acc     types.AccountID
	Deposit types.U128
	Topics  []types.Hash
}

type Event_ClearInvalidFile

type Event_ClearInvalidFile struct {
	Phase     types.Phase
	Acc       types.AccountID
	File_hash [64]types.U8
	Topics    []types.Hash
}

type Event_CreateBucket

type Event_CreateBucket struct {
	Phase       types.Phase
	Acc         types.AccountID
	Owner       types.AccountID
	Bucket_name types.Bytes
	Topics      []types.Hash
}

type Event_DeleteBucket

type Event_DeleteBucket struct {
	Phase       types.Phase
	Acc         types.AccountID
	Owner       types.AccountID
	Bucket_name types.Bytes
	Topics      []types.Hash
}

type Event_DeleteFile

type Event_DeleteFile struct {
	Phase    types.Phase
	Operator types.AccountID
	Owner    types.AccountID
	Filehash FileHash
	Topics   []types.Hash
}

------------------------FileBank----------------------

type Event_Deposit

type Event_Deposit struct {
	Phase   types.Phase
	Balance types.U128
	Topics  []types.Hash
}

type Event_DrawFaucetMoney

type Event_DrawFaucetMoney struct {
	Phase  types.Phase
	Topics []types.Hash
}

type Event_EndOfBufferPeriod

type Event_EndOfBufferPeriod struct {
	Phase  types.Phase
	When   types.U32
	Topics []types.Hash
}

type Event_ExpansionSpace

type Event_ExpansionSpace struct {
	Phase           types.Phase
	Acc             types.AccountID
	Expansion_space types.U128
	Fee             types.U128
	Topics          []types.Hash
}

type Event_FaucetTopUpMoney

type Event_FaucetTopUpMoney struct {
	Phase  types.Phase
	Acc    types.AccountID
	Topics []types.Hash
}

type Event_FileChangeState

type Event_FileChangeState struct {
	Phase  types.Phase
	Acc    types.AccountID
	Fileid types.Bytes
	Topics []types.Hash
}

type Event_FileUpdate

type Event_FileUpdate struct {
	Phase  types.Phase
	Acc    types.AccountID
	Fileid types.Bytes
	Topics []types.Hash
}

type Event_FileUpload

type Event_FileUpload struct {
	Phase  types.Phase
	Acc    types.AccountID
	Topics []types.Hash
}

type Event_FillerUpload

type Event_FillerUpload struct {
	Phase    types.Phase
	Acc      types.AccountID
	Filesize types.U64
	Topics   []types.Hash
}

type Event_IncreaseCollateral

type Event_IncreaseCollateral struct {
	Phase   types.Phase
	Acc     types.AccountID
	Balance types.U128
	Topics  []types.Hash
}

type Event_InsertFileSlice

type Event_InsertFileSlice struct {
	Phase  types.Phase
	Fileid types.Bytes
	Topics []types.Hash
}

type Event_LeaseExpireIn24Hours

type Event_LeaseExpireIn24Hours struct {
	Phase  types.Phase
	Acc    types.AccountID
	Size   types.U128
	Topics []types.Hash
}

type Event_LeaseExpired

type Event_LeaseExpired struct {
	Phase  types.Phase
	Acc    types.AccountID
	Size   types.U128
	Topics []types.Hash
}

type Event_LessThan24Hours

type Event_LessThan24Hours struct {
	Phase  types.Phase
	Last   types.U32
	Now    types.U32
	Topics []types.Hash
}

type Event_MinerClaim

type Event_MinerClaim struct {
	Phase  types.Phase
	Acc    types.AccountID
	Topics []types.Hash
}

type Event_MinerExit

type Event_MinerExit struct {
	Phase  types.Phase
	Acc    types.AccountID
	Topics []types.Hash
}

type Event_OssDestroy added in v0.0.24

type Event_OssDestroy struct {
	Phase  types.Phase
	Acc    types.AccountID
	Topics []types.Hash
}

type Event_OssRegister

type Event_OssRegister struct {
	Phase    types.Phase
	Acc      types.AccountID
	Endpoint types.Bytes
	Topics   []types.Hash
}

------------------------Oss---------------------------

type Event_OssUpdate

type Event_OssUpdate struct {
	Phase        types.Phase
	Acc          types.AccountID
	New_endpoint types.Bytes
	Topics       []types.Hash
}

type Event_OutstandingChallenges

type Event_OutstandingChallenges struct {
	Phase  types.Phase
	Miner  types.AccountID
	Fileid types.Bytes
	Topics []types.Hash
}

type Event_PPBNoOnTimeSubmit

type Event_PPBNoOnTimeSubmit struct {
	Phase     types.Phase
	Acc       types.AccountID
	SegmentId types.U64
	Topics    []types.Hash
}

------------------------SegmentBook-------------------

type Event_PPDNoOnTimeSubmit

type Event_PPDNoOnTimeSubmit struct {
	Phase     types.Phase
	Acc       types.AccountID
	SegmentId types.U64
	Topics    []types.Hash
}

type Event_Purchased

type Event_Purchased struct {
	Phase  types.Phase
	Acc    types.AccountID
	Fileid types.Bytes
	Topics []types.Hash
}

type Event_ReceiveSpace

type Event_ReceiveSpace struct {
	Phase  types.Phase
	Acc    types.AccountID
	Topics []types.Hash
}

type Event_RecoverFile

type Event_RecoverFile struct {
	Phase     types.Phase
	Acc       types.AccountID
	File_hash [68]types.U8
	Topics    []types.Hash
}

type Event_Redeemed

type Event_Redeemed struct {
	Phase   types.Phase
	Acc     types.AccountID
	Deposit types.U128
	Topics  []types.Hash
}

type Event_Registered

type Event_Registered struct {
	Phase      types.Phase
	Acc        types.AccountID
	StakingVal types.U128
	Topics     []types.Hash
}

------------------------Sminer------------------------

type Event_RegistrationScheduler

type Event_RegistrationScheduler struct {
	Phase  types.Phase
	Acc    types.AccountID
	Ip     types.Bytes
	Topics []types.Hash
}

------------------------TEE Worker--------------------

type Event_RenewalSpace

type Event_RenewalSpace struct {
	Phase        types.Phase
	Acc          types.AccountID
	Renewal_days types.U32
	Fee          types.U128
	Topics       []types.Hash
}

type Event_ReplaceFiller added in v0.0.11

type Event_ReplaceFiller struct {
	Phase       types.Phase
	Acc         types.AccountID
	Filler_list []FileHash
	Topics      []types.Hash
}

type Event_SignedPhaseStarted

type Event_SignedPhaseStarted struct {
	Phase  types.Phase
	Round  types.U32
	Topics []types.Hash
}

type Event_SolutionStored

type Event_SolutionStored struct {
	Phase            types.Phase
	Election_compute types.ElectionCompute
	Prev_ejected     types.Bool
	Topics           []types.Hash
}

type Event_StartOfBufferPeriod

type Event_StartOfBufferPeriod struct {
	Phase  types.Phase
	When   types.U32
	Topics []types.Hash
}

type Event_TimedTask

type Event_TimedTask struct {
	Phase  types.Phase
	Topics []types.Hash
}

type Event_TimingStorageSpace

type Event_TimingStorageSpace struct {
	Phase  types.Phase
	Topics []types.Hash
}

type Event_TransferReport added in v0.0.11

type Event_TransferReport struct {
	Phase       types.Phase
	Acc         types.AccountID
	Failed_list []FileHash
	Topics      []types.Hash
}

type Event_UnsignedPhaseStarted

type Event_UnsignedPhaseStarted struct {
	Phase  types.Phase
	Round  types.U32
	Topics []types.Hash
}

------------------------System------------------------

type Event_UpdataBeneficiary

type Event_UpdataBeneficiary struct {
	Phase  types.Phase
	Acc    types.AccountID
	New    types.AccountID
	Topics []types.Hash
}

type Event_UpdataIp

type Event_UpdataIp struct {
	Phase  types.Phase
	Acc    types.AccountID
	Old    types.Bytes
	New    types.Bytes
	Topics []types.Hash
}

type Event_UpdateScheduler

type Event_UpdateScheduler struct {
	Phase    types.Phase
	Acc      types.AccountID
	Endpoint types.Bytes
	Topics   []types.Hash
}

type Event_UploadDeclaration

type Event_UploadDeclaration struct {
	Phase     types.Phase
	Operator  types.AccountID
	Owner     types.AccountID
	Deal_hash FileHash
	Topics    []types.Hash
}

type Event_VerifyProof

type Event_VerifyProof struct {
	Phase  types.Phase
	Miner  types.AccountID
	Fileid types.Bytes
	Topics []types.Hash
}

type FileHash

type FileHash [64]types.U8

type FileMetaInfo

type FileMetaInfo struct {
	Completion  types.U32
	State       types.U8
	SegmentList []SegmentInfo
	Owner       []UserBrief
}

type FragmentList

type FragmentList struct {
	Hash  FileHash
	Avail types.Bool
	Miner types.AccountID
}

type IdleMetaInfo added in v0.0.6

type IdleMetaInfo struct {
	Size      types.U64
	BlockNum  types.U32
	BlockSize types.U32
	ScanSize  types.U32
	Acc       types.AccountID
	Hash      FileHash
}

type MinerInfo

type MinerInfo struct {
	PeerId      types.U64
	IncomeAcc   types.AccountID
	Ip          types.Bytes
	Collaterals types.U128
	State       types.Bytes
	Power       types.U128
	Space       types.U128
	RewardInfo  RewardInfo
}

type MinerSnapShot added in v0.0.26

type MinerSnapShot struct {
	Miner         types.AccountID
	Idle_space    types.U128
	Service_space types.U128
}

type MinerTaskList

type MinerTaskList struct {
	Account types.AccountID
	Hash    []FileHash
}

type NetSnapShot added in v0.0.26

type NetSnapShot struct {
	NetSnapShot   NetSnapShotStorage
	MinerSnapShot []MinerSnapShot
}

type NetSnapShotStorage added in v0.0.26

type NetSnapShotStorage struct {
	Start               types.U32
	Total_reward        types.U128
	Total_idle_space    types.U128
	Total_service_space types.U128
	Random              Random
}

type Random added in v0.0.26

type Random [20]types.U8

type RewardInfo

type RewardInfo struct {
	Total       types.U128
	Received    types.U128
	NotReceived types.U128
}

type SegmentInfo

type SegmentInfo struct {
	Hash         FileHash
	FragmentList []FragmentList
}

type SegmentList

type SegmentList struct {
	SegmentHash  FileHash
	FragmentHash []FileHash
}

type StorageOrder

type StorageOrder struct {
	Stage         types.U8
	Count         types.U8
	SegmentList   []SegmentList
	NeededList    []SegmentList
	User          UserBrief
	AssignedMiner []MinerTaskList
	ShareInfo     []SegmentInfo
	CompleteList  []types.AccountID
}

type UserBrief

type UserBrief struct {
	User        types.AccountID
	File_name   types.Bytes
	Bucket_name types.Bytes
}

type UserSpaceInfo added in v0.0.24

type UserSpaceInfo struct {
	TotalSpace     types.U128
	UsedSpace      types.U128
	LockedSpace    types.U128
	RemainingSpace types.U128
	Start          types.U32
	Deadline       types.U32
	State          types.Bytes
}

Jump to

Keyboard shortcuts

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