ontfs

package
v1.14.4 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: LGPL-3.0 Imports: 17 Imported by: 5

Documentation

Index

Constants

View Source
const (
	DefaultMinTimeForFileStorage = 60 * 60 * 24 //1day
	DefaultContractInvokeGasFee  = 10000000     //0.01ong
	DefaultChallengeReward       = 100000000    //0.1ong
	DefaultFilePerServerPdpTimes = 2
	DefaultPassportExpire        = 9           //block count. passport expire for GetFileHashList
	DefaultNodeMinVolume         = 1024 * 1024 //kb. min total volume with single fsNode
	DefaultChallengeInterval     = 1 * 60 * 60 //1hour
	DefaultNodePerKbPledge       = 1024 * 100  //fsNode's pledge for participant
	DefaultFilePerBlockFeeRate   = 60          //file mode cost of per block save from fsNode for one minute
	DefaultSpacePerBlockFeeRate  = 60          //space mode cost of per block save from fsNode for one hour
	DefaultGasPerBlockForRead    = 256         //cost of per block read from fsNode
)
View Source
const (
	Judged = iota
	NoReplyAndValid
	NoReplyAndExpire
	RepliedAndSuccess
	RepliedButVerifyError
)

challenge state

View Source
const (
	FileStorageTypeUseSpace = 0
	FileStorageTypeUseFile  = 1
)
View Source
const (
	FS_SET_GLOBAL_PARAM        = "FsSetGlobalParam"
	FS_GET_GLOBAL_PARAM        = "FsGetGlobalParam"
	FS_NODE_REGISTER           = "FsNodeRegister"
	FS_NODE_QUERY              = "FsNodeQuery"
	FS_NODE_UPDATE             = "FsNodeUpdate"
	FS_NODE_CANCEL             = "FsNodeCancel"
	FS_FILE_PROVE              = "FsFileProve"
	FS_NODE_WITHDRAW_PROFIT    = "FsNodeWithdrawProfit"
	FS_CHALLENGE               = "FsChallenge"
	FS_GET_CHALLENGE           = "FsGetChallenge"
	FS_GET_FILE_CHALLENGE_LIST = "FsGetFileChallengeList"
	FS_GET_NODE_CHALLENGE_LIST = "FsGetNodeChallengeList"
	FS_RESPONSE                = "FsResponse"
	FS_JUDGE                   = "FsJudge"
	FS_GET_NODE_LIST           = "FsGetNodeList"
	FS_GET_PDP_INFO_LIST       = "FsGetPdpInfoList"
	FS_STORE_FILES             = "FsStoreFiles"
	FS_RENEW_FILES             = "FsRenewFiles"
	FS_DELETE_FILES            = "FsDeleteFiles"
	FS_TRANSFER_FILES          = "FsTransferFiles"
	FS_GET_FILE_INFO           = "FsGetFileInfo"
	FS_GET_FILE_LIST           = "FsGetFileList"
	FS_READ_FILE_PLEDGE        = "FsReadFilePledge"
	FS_READ_FILE_SETTLE        = "FsReadFileSettle"
	FS_GET_READ_PLEDGE         = "FsGetReadPledge"
	FS_CREATE_SPACE            = "FsCreateSpace"
	FS_DELETE_SPACE            = "FsDeleteSpace"
	FS_UPDATE_SPACE            = "FsUpdateSpace"
	FS_GET_SPACE_INFO          = "FsGetSpaceInfo"
)
View Source
const (
	ONTFS_GLOBAL_PARAM     = "ontFsGlobalParam"
	ONTFS_CHALLENGE        = "ontFsChallenge"
	ONTFS_RESPONSE         = "ontFsResponse"
	ONTFS_NODE_INFO        = "ontFsNodeInfo"
	ONTFS_FILE_INFO        = "ontFsFileInfo"
	ONTFS_FILE_PDP         = "ontFsFilePdp"
	ONTFS_FILE_OWNER       = "ontFsFileOwner"
	ONTFS_FILE_READ_PLEDGE = "ontFsFileReadPledge"
	ONTFS_FILE_SPACE       = "ontFsFileSpace"
)
View Source
const (
	DefaultPerBlockSize = 256 //kb.
)
View Source
const Hour = 3600

Variables

This section is empty.

Functions

func CheckOntFsAvailability added in v1.11.0

func CheckOntFsAvailability(service *native.NativeService) error

func CheckPassport

func CheckPassport(currBlockHeight uint64, passportExpire uint64, passportData []byte) (common.Address, error)

func CheckPdpProve

func CheckPdpProve(nodeAddr common.Address, blockHash []byte, fileBlockCount uint64, fileUniqueId []byte,
	proofData []byte) error

func DecodeBool

func DecodeBool(source *common.ZeroCopySource) (bool, error)

func DecodeVarBytes

func DecodeVarBytes(source *common.ZeroCopySource) ([]byte, error)

func EncRet

func EncRet(ret bool, info []byte) []byte

func FsChallenge

func FsChallenge(native *native.NativeService) ([]byte, error)

func FsCreateSpace

func FsCreateSpace(native *native.NativeService) ([]byte, error)

func FsDeleteFiles

func FsDeleteFiles(native *native.NativeService) ([]byte, error)

func FsDeleteSpace

func FsDeleteSpace(native *native.NativeService) ([]byte, error)

func FsFileProve

func FsFileProve(native *native.NativeService) ([]byte, error)

func FsGetChallenge

func FsGetChallenge(native *native.NativeService) ([]byte, error)

func FsGetFileChallengeList

func FsGetFileChallengeList(native *native.NativeService) ([]byte, error)

func FsGetFileHashList

func FsGetFileHashList(native *native.NativeService) ([]byte, error)

func FsGetFileInfo

func FsGetFileInfo(native *native.NativeService) ([]byte, error)

func FsGetGlobalParam

func FsGetGlobalParam(native *native.NativeService) ([]byte, error)

func FsGetNodeChallengeList

func FsGetNodeChallengeList(native *native.NativeService) ([]byte, error)

func FsGetNodeInfoList

func FsGetNodeInfoList(native *native.NativeService) ([]byte, error)

func FsGetPdpInfoList

func FsGetPdpInfoList(native *native.NativeService) ([]byte, error)

func FsGetReadPledge

func FsGetReadPledge(native *native.NativeService) ([]byte, error)

func FsGetSpaceInfo

func FsGetSpaceInfo(native *native.NativeService) ([]byte, error)

func FsJudge

func FsJudge(native *native.NativeService) ([]byte, error)

func FsNodeCancel

func FsNodeCancel(native *native.NativeService) ([]byte, error)

func FsNodeQuery

func FsNodeQuery(native *native.NativeService) ([]byte, error)

func FsNodeRegister

func FsNodeRegister(native *native.NativeService) ([]byte, error)

func FsNodeUpdate

func FsNodeUpdate(native *native.NativeService) ([]byte, error)

func FsNodeWithdrawProfit

func FsNodeWithdrawProfit(native *native.NativeService) ([]byte, error)

func FsReadFilePledge

func FsReadFilePledge(native *native.NativeService) ([]byte, error)

func FsReadFileSettle

func FsReadFileSettle(native *native.NativeService) ([]byte, error)

func FsRenewFiles

func FsRenewFiles(native *native.NativeService) ([]byte, error)

func FsResponse

func FsResponse(native *native.NativeService) ([]byte, error)

func FsSetGlobalParam

func FsSetGlobalParam(native *native.NativeService) ([]byte, error)

To enable administrators to adjust global parameters

func FsStoreFiles

func FsStoreFiles(native *native.NativeService) ([]byte, error)

func FsTransferFiles

func FsTransferFiles(native *native.NativeService) ([]byte, error)

func FsUpdateSpace

func FsUpdateSpace(native *native.NativeService) ([]byte, error)

func GenChallengeKey

func GenChallengeKey(contract common.Address, nodeAddr common.Address, fileHash []byte) []byte

func GenChallengePrefix

func GenChallengePrefix(contract common.Address, nodeAddr common.Address) []byte

func GenFsFileInfoKey

func GenFsFileInfoKey(contract common.Address, fileOwner common.Address, fileHash []byte) []byte

func GenFsFileInfoPrefix

func GenFsFileInfoPrefix(contract common.Address, fileOwner common.Address) []byte

func GenFsFileOwnerKey

func GenFsFileOwnerKey(contract common.Address, fileHash []byte) []byte

func GenFsNodeInfoKey

func GenFsNodeInfoKey(contract common.Address, nodeAddr common.Address) []byte

func GenFsNodeInfoPrefix

func GenFsNodeInfoPrefix(contract common.Address) []byte

func GenFsPdpRecordKey

func GenFsPdpRecordKey(contract common.Address, fileHash []byte, fileOwner common.Address, nodeAddr common.Address) []byte

func GenFsPdpRecordPrefix

func GenFsPdpRecordPrefix(contract common.Address, fileHash []byte, fileOwner common.Address) []byte

func GenFsReadPledgeKey

func GenFsReadPledgeKey(contract common.Address, downloader common.Address, fileHash []byte) []byte

func GenFsSpaceKey

func GenFsSpaceKey(contract common.Address, spaceOwner common.Address) []byte

func GenGlobalParamKey

func GenGlobalParamKey(contract common.Address) []byte

func GenResponseKey

func GenResponseKey(contract common.Address, fileOwner common.Address, fileHash []byte) []byte

func GenResponsePrefix

func GenResponsePrefix(contract common.Address, fileOwner common.Address) []byte

func InitFs

func InitFs()

func RegisterFsContract

func RegisterFsContract(native *native.NativeService)

Types

type Challenge

type Challenge struct {
	FileHash        []byte
	FileOwner       common.Address
	NodeAddr        common.Address
	ChallengeHeight uint64
	Reward          uint64
	ExpiredTime     uint64
	State           uint64
}

func (*Challenge) Deserialization

func (this *Challenge) Deserialization(source *common.ZeroCopySource) error

func (*Challenge) Serialization

func (this *Challenge) Serialization(sink *common.ZeroCopySink)

type ChallengeList

type ChallengeList struct {
	Challenges []Challenge
}

func (*ChallengeList) Deserialization

func (this *ChallengeList) Deserialization(source *common.ZeroCopySource) error

func (*ChallengeList) Serialization

func (this *ChallengeList) Serialization(sink *common.ZeroCopySink)

type Errors

type Errors struct {
	ObjectErrors map[string]string
}

func (*Errors) AddErrorsEvent

func (this *Errors) AddErrorsEvent(native *native.NativeService)

func (*Errors) AddObjectError

func (this *Errors) AddObjectError(object string, errorString string)

func (*Errors) FromString

func (this *Errors) FromString(errors string) error

func (*Errors) PrintErrors

func (this *Errors) PrintErrors()

func (*Errors) ToString

func (this *Errors) ToString() string

type FileDel

type FileDel struct {
	FileHash []byte
}

func (*FileDel) Deserialization

func (this *FileDel) Deserialization(source *common.ZeroCopySource) error

func (*FileDel) Serialization

func (this *FileDel) Serialization(sink *common.ZeroCopySink)

type FileDelList

type FileDelList struct {
	FilesDel []FileDel
}

func (*FileDelList) Deserialization

func (this *FileDelList) Deserialization(source *common.ZeroCopySource) error

func (*FileDelList) Serialization

func (this *FileDelList) Serialization(sink *common.ZeroCopySink)

type FileHash

type FileHash struct {
	FHash []byte
}

type FileHashList

type FileHashList struct {
	FilesH []FileHash
}

func (*FileHashList) Deserialization

func (this *FileHashList) Deserialization(source *common.ZeroCopySource) error

func (*FileHashList) Serialization

func (this *FileHashList) Serialization(sink *common.ZeroCopySink)

type FileInfo

type FileInfo struct {
	FileHash       []byte
	FileOwner      common.Address
	FileDesc       []byte
	FileBlockCount uint64
	RealFileSize   uint64
	CopyNumber     uint64
	PayAmount      uint64
	RestAmount     uint64
	FirstPdp       bool
	TimeStart      uint64
	TimeExpired    uint64
	BeginHeight    uint64
	ExpiredHeight  uint64
	PdpParam       []byte
	ValidFlag      bool
	CurrFeeRate    uint64
	StorageType    uint64
}

func (*FileInfo) Deserialization

func (this *FileInfo) Deserialization(source *common.ZeroCopySource) error

func (*FileInfo) Serialization

func (this *FileInfo) Serialization(sink *common.ZeroCopySink)

type FileInfoList

type FileInfoList struct {
	FilesI []FileInfo
}

func (*FileInfoList) Deserialization

func (this *FileInfoList) Deserialization(source *common.ZeroCopySource) error

func (*FileInfoList) Serialization

func (this *FileInfoList) Serialization(sink *common.ZeroCopySink)

type FileReNew

type FileReNew struct {
	FileHash       []byte
	FileOwner      common.Address
	Payer          common.Address
	NewTimeExpired uint64
}

func (*FileReNew) Deserialization

func (this *FileReNew) Deserialization(source *common.ZeroCopySource) error

func (*FileReNew) Serialization

func (this *FileReNew) Serialization(sink *common.ZeroCopySink)

type FileReNewList

type FileReNewList struct {
	FilesReNew []FileReNew
}

func (*FileReNewList) Deserialization

func (this *FileReNewList) Deserialization(source *common.ZeroCopySource) error

func (*FileReNewList) Serialization

func (this *FileReNewList) Serialization(sink *common.ZeroCopySink)

type FileReadSettleSlice

type FileReadSettleSlice struct {
	FileHash     []byte
	PayFrom      common.Address
	PayTo        common.Address
	SliceId      uint64
	PledgeHeight uint64
	Sig          []byte
	PubKey       []byte
}

func (*FileReadSettleSlice) Deserialization

func (this *FileReadSettleSlice) Deserialization(source *common.ZeroCopySource) error

func (*FileReadSettleSlice) Serialization

func (this *FileReadSettleSlice) Serialization(sink *common.ZeroCopySink)

type FileTransfer

type FileTransfer struct {
	FileHash []byte
	OriOwner common.Address
	NewOwner common.Address
}

func (*FileTransfer) Deserialization

func (this *FileTransfer) Deserialization(source *common.ZeroCopySource) error

func (*FileTransfer) Serialization

func (this *FileTransfer) Serialization(sink *common.ZeroCopySink)

type FileTransferList

type FileTransferList struct {
	FilesTransfer []FileTransfer
}

func (*FileTransferList) Deserialization

func (this *FileTransferList) Deserialization(source *common.ZeroCopySource) error

func (*FileTransferList) Serialization

func (this *FileTransferList) Serialization(sink *common.ZeroCopySink)

type FsGlobalParam

type FsGlobalParam struct {
	MinTimeForFileStorage uint64
	ContractInvokeGasFee  uint64
	ChallengeReward       uint64
	FilePerServerPdpTimes uint64
	PassportExpire        uint64
	ChallengeInterval     uint64
	NodeMinVolume         uint64 //min total volume with fsNode
	NodePerKbPledge       uint64 //fsNode's pledge for participant
	FeePerBlockForRead    uint64 //cost for ontfs-sdk read from fsNode
	FilePerBlockFeeRate   uint64 //cost for ontfs-sdk save from fsNode
	SpacePerBlockFeeRate  uint64 //cost for ontfs-sdk save from fsNode
}

func (*FsGlobalParam) Deserialization

func (this *FsGlobalParam) Deserialization(source *common.ZeroCopySource) error

func (*FsGlobalParam) Serialization

func (this *FsGlobalParam) Serialization(sink *common.ZeroCopySink)

type FsNodeInfo

type FsNodeInfo struct {
	Pledge      uint64
	Profit      uint64
	Volume      uint64
	RestVol     uint64
	ServiceTime uint64
	NodeAddr    common.Address
	NodeNetAddr []byte
}

func (*FsNodeInfo) Deserialization

func (this *FsNodeInfo) Deserialization(source *common.ZeroCopySource) error

func (*FsNodeInfo) Serialization

func (this *FsNodeInfo) Serialization(sink *common.ZeroCopySink)

type FsNodeInfoList

type FsNodeInfoList struct {
	NodesInfo []FsNodeInfo
}

func (*FsNodeInfoList) Deserialization

func (this *FsNodeInfoList) Deserialization(source *common.ZeroCopySource) error

func (*FsNodeInfoList) Serialization

func (this *FsNodeInfoList) Serialization(sink *common.ZeroCopySink)

type GetReadPledge

type GetReadPledge struct {
	FileHash   []byte
	Downloader common.Address
}

func (*GetReadPledge) Deserialization

func (this *GetReadPledge) Deserialization(source *common.ZeroCopySource) error

func (*GetReadPledge) Serialization

func (this *GetReadPledge) Serialization(sink *common.ZeroCopySink)

type Passport

type Passport struct {
	BlockHeight uint64
	BlockHash   []byte
	WalletAddr  common.Address
	PublicKey   []byte
	Signature   []byte
}

func (*Passport) Deserialization

func (this *Passport) Deserialization(source *common.ZeroCopySource) error

func (*Passport) Serialization

func (this *Passport) Serialization(sink *common.ZeroCopySink)

type PdpData

type PdpData struct {
	NodeAddr        common.Address
	FileHash        []byte
	ProveData       []byte
	ChallengeHeight uint64
}

func (*PdpData) Deserialization

func (this *PdpData) Deserialization(source *common.ZeroCopySource) error

func (*PdpData) Serialization

func (this *PdpData) Serialization(sink *common.ZeroCopySink) error

type PdpRecord

type PdpRecord struct {
	NodeAddr    common.Address
	FileHash    []byte
	FileOwner   common.Address
	LastPdpTime uint64
	SettleFlag  bool
}

func (*PdpRecord) Deserialization

func (this *PdpRecord) Deserialization(source *common.ZeroCopySource) error

func (*PdpRecord) Serialization

func (this *PdpRecord) Serialization(sink *common.ZeroCopySink)

type PdpRecordKey

type PdpRecordKey struct {
	RecordKey []byte
}

type PdpRecordList

type PdpRecordList struct {
	PdpRecords []PdpRecord
}

func (*PdpRecordList) Deserialization

func (this *PdpRecordList) Deserialization(source *common.ZeroCopySource) error

func (*PdpRecordList) Serialization

func (this *PdpRecordList) Serialization(sink *common.ZeroCopySink)

type ReadPlan

type ReadPlan struct {
	NodeAddr         common.Address
	MaxReadBlockNum  uint64
	HaveReadBlockNum uint64
	NumOfSettlements uint64
}

func (*ReadPlan) Deserialization

func (this *ReadPlan) Deserialization(source *common.ZeroCopySource) error

func (*ReadPlan) Serialization

func (this *ReadPlan) Serialization(sink *common.ZeroCopySink)

type ReadPledge

type ReadPledge struct {
	FileHash   []byte
	Downloader common.Address
	RestMoney  uint64
	ReadPlans  []ReadPlan
}

func (*ReadPledge) Deserialization

func (this *ReadPledge) Deserialization(source *common.ZeroCopySource) error

func (*ReadPledge) Serialization

func (this *ReadPledge) Serialization(sink *common.ZeroCopySink)

type RetInfo

type RetInfo struct {
	Ret  bool
	Info []byte
}

func DecRet

func DecRet(ret []byte) (*RetInfo, error)

func (*RetInfo) Deserialization

func (this *RetInfo) Deserialization(source *common.ZeroCopySource) error

func (*RetInfo) Serialization

func (this *RetInfo) Serialization(sink *common.ZeroCopySink)

type SpaceInfo

type SpaceInfo struct {
	SpaceOwner  common.Address
	Volume      uint64
	RestVol     uint64
	CopyNumber  uint64
	PayAmount   uint64
	RestAmount  uint64
	TimeStart   uint64
	TimeExpired uint64
	CurrFeeRate uint64
	ValidFlag   bool
}

func (*SpaceInfo) Deserialization

func (this *SpaceInfo) Deserialization(source *common.ZeroCopySource) error

func (*SpaceInfo) Serialization

func (this *SpaceInfo) Serialization(sink *common.ZeroCopySink)

type SpaceUpdate

type SpaceUpdate struct {
	SpaceOwner     common.Address
	Payer          common.Address
	NewVolume      uint64
	NewTimeExpired uint64
}

func (*SpaceUpdate) Deserialization

func (this *SpaceUpdate) Deserialization(source *common.ZeroCopySource) error

func (*SpaceUpdate) Serialization

func (this *SpaceUpdate) Serialization(sink *common.ZeroCopySink)

Directories

Path Synopsis
pdp

Jump to

Keyboard shortcuts

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