event

package
v0.11.9 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: Apache-2.0 Imports: 51 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SliceInvalid  = 0
	SliceUpload   = 1
	SliceDownload = 2
	SliceBackup   = 3
	SliceTransfer = 4
)
View Source
const CHECK_TRANFER_FAILURE_INTERVAL = 60 // in seconds
View Source
const DOWNLOAD_SLICE_TIMEOUT = 180
View Source
const (
	LOSE_SLICE_MSG = "cannot find the file slice"
)

Variables

View Source
var (
	DownSendCostTimeMap = &downSendCostTime{
		dataMap: utils.NewAutoCleanUnsafeMap(30 * time.Minute),
		mux:     sync.Mutex{},
	}
	DownRecvCostTimeMap = &downRecvCostTime{
		dataMap: utils.NewAutoCleanUnsafeMap(30 * time.Minute),
		mux:     sync.Mutex{},
	}
)
View Source
var (

	//// Maps to record uploading stats
	PacketIdMap       = &sync.Map{} // K: reqId, V: TaskSlice{tkId+sliceNum, up/down}
	UpSendCostTimeMap = &upSendCostTime{
		dataMap: utils.NewAutoCleanUnsafeMap(30 * time.Minute),
		mux:     sync.Mutex{},
	}
	UpRecvCostTimeMap = &upRecvCostTime{
		dataMap: utils.NewAutoCleanUnsafeMap(30 * time.Minute),
		mux:     sync.Mutex{},
	}
)

Functions

func Activate

func Activate(ctx context.Context, amount utiltypes.Coin, txFee utiltypes.TxFee) error

Activate Inactive PP node becomes active

func BackupFileSlice added in v0.10.0

func BackupFileSlice(ctx context.Context, tk *task.UploadSliceTask) error

func CheckAndSendRetryMessage added in v0.7.0

func CheckAndSendRetryMessage(ctx context.Context, dTask *task.DownloadTask)

func CheckTransferTimeout added in v0.11.0

func CheckTransferTimeout(ctx context.Context) func()
func ClearExpiredShareLinks(ctx context.Context, walletAddr string, walletPubkey, wsign []byte, reqTime int64)

func ClearFileInfoAndDownloadTask

func ClearFileInfoAndDownloadTask(ctx context.Context, fileHash string, fileReqId string, w http.ResponseWriter)

func CreateAndSimulateTx added in v0.10.0

func CreateAndSimulateTx(txMsg sdktypes.Msg, msgType string, txFee types.TxFee, memo string, signatureKeys []relaytypes.SignatureKey) ([]byte, error)

func Deactivate

func Deactivate(ctx context.Context, txFee utiltypes.TxFee) error

Deactivate Request that an active PP node becomes inactive

func DeleteFile

func DeleteFile(ctx context.Context, fileHash string, walletAddr string, walletPubkey, wsign []byte, reqTime int64)

func DeleteShare

func DeleteShare(ctx context.Context, shareID, walletAddress string, walletPubkey, wsign []byte, reqTime int64)

func DownloadFileSlices added in v0.11.0

func DownloadFileSlices(ctx context.Context, target *protos.RspFileStorageInfo, reqId string)

func DownloadSliceCancel

func DownloadSliceCancel(ctx context.Context, fileHash, reqID string)

func DownloadSlicePause

func DownloadSlicePause(ctx context.Context, fileHash, reqID string)

func FindFileList added in v0.9.0

func FindFileList(ctx context.Context, fileName string, walletAddr string, pageId uint64, keyword string, fileType int,
	isUp bool, walletPubkey, wsign []byte, reqTime int64)
func GetAllShareLink(ctx context.Context, walletAddr string, page uint64, walletPubkey, wsign []byte, reqTime int64)

func GetFilePath added in v0.11.0

func GetFilePath(key string) string

func GetFileReplicaInfo added in v0.10.0

func GetFileReplicaInfo(ctx context.Context, path string, replicaIncreaseNum uint32)

func GetFileStatus added in v0.10.0

func GetFileStatus(ctx context.Context, fileHash, walletAddr string, walletPubkey, walletSign []byte, reqTime int64) *protos.RspFileStatus

GetFileStatus checks if the specified file is currently being uploaded. If it isn't, it queries the file status from SP to know if the upload succeeded or failed

func GetFileStorageInfo

func GetFileStorageInfo(ctx context.Context, path, savePath, saveAs string, w http.ResponseWriter)

GetFileStorageInfo p to pp. The downloader is assumed the default wallet of this node, if this function is invoked.

func GetOngoingDownloadTaskCount added in v0.10.0

func GetOngoingDownloadTaskCount() int

func GetOngoingUploadTaskCount added in v0.10.0

func GetOngoingUploadTaskCount() int

func GetReqShareFile

func GetReqShareFile(ctx context.Context, fileHash, pathHash, walletAddr string, shareTime int64, isPrivate bool,
	walletPubkey, wsign []byte, reqTime int64)

func GetShareFile

func GetShareFile(ctx context.Context, keyword, sharePassword, saveAs, walletAddr string, walletPubkey []byte,
	isVideoStream bool, wsign []byte, reqTime int64)

func GetWalletOz added in v0.6.0

func GetWalletOz(ctx context.Context, walletAddr, reqId string) error

GetWalletOz queries current ozone balance

func HandleSendPacketCostTime added in v0.9.0

func HandleSendPacketCostTime(ctx context.Context, packetId, costTime int64, conn core.WriteCloser)

func NoticeActivatedPP added in v0.10.0

func NoticeActivatedPP(ctx context.Context, conn core.WriteCloser)

NoticeActivatedPP Notice when this PP node was successfully activated

func NoticeDeactivatedPP added in v0.10.0

func NoticeDeactivatedPP(ctx context.Context, conn core.WriteCloser)

NoticeDeactivatedPP Notice when this PP node was successfully deactivated after threshold period (180 days)

func NoticeFileSliceBackup added in v0.10.0

func NoticeFileSliceBackup(ctx context.Context, conn core.WriteCloser)

NoticeFileSliceBackup An SP node wants this PP node to fetch the specified slice from the PP node who stores it. Both backups and transfers use the same method

func NoticeFileSliceBackupVerifier added in v0.10.0

func NoticeFileSliceBackupVerifier(ctx context.Context, msgType header.MsgType, target interface{}) error

NoticeFileSliceBackupVerifier task level verifier for all messages carrying NoticeFileSliceBackup in a transfer task

func NoticeSpUnderMaintenance added in v0.10.0

func NoticeSpUnderMaintenance(ctx context.Context, conn core.WriteCloser)

func NoticeUnbondingPP added in v0.10.0

func NoticeUnbondingPP(ctx context.Context, conn core.WriteCloser)

NoticeUnbondingPP Notice when this PP node unbonded all its deposit

func NoticeUpdatedDeposit added in v0.10.0

func NoticeUpdatedDeposit(ctx context.Context, conn core.WriteCloser)

NoticeUpdatedDeposit Notice when this PP node's deposit was successfully updated

func PpRspVerifier added in v0.10.0

func PpRspVerifier(ctx context.Context, msgType header.MsgType, target interface{}) error

func Prepay

func Prepay(ctx context.Context, beneficiary []byte, amount utiltypes.Coin, txFee utiltypes.TxFee,
	walletAddr string, walletPubkey, wsign []byte, reqTime int64) error

Prepay PP node sends a prepay transaction

func RegisterAllEventHandlers added in v0.10.0

func RegisterAllEventHandlers()

RegisterAllEventHandler

func RegisterNewPP

func RegisterNewPP(ctx context.Context, walletAddr string, walletPubkey, wsig []byte, reqTime int64)

RegisterNewPP P-SP P register to become PP

func ReqBackupFileSlice added in v0.10.0

func ReqBackupFileSlice(ctx context.Context, conn core.WriteCloser)

ReqBackupFileSlice

func ReqBackupStatus added in v0.8.0

func ReqBackupStatus(ctx context.Context, fileHash string)

func ReqClearDownloadTask

func ReqClearDownloadTask(ctx context.Context, conn core.WriteCloser)

func ReqDownloadSlice

func ReqDownloadSlice(ctx context.Context, conn core.WriteCloser)

ReqDownloadSlice download slice PP-storagePP

func ReqFileStorageInfo

func ReqFileStorageInfo(ctx context.Context, conn core.WriteCloser)

ReqFileStorageInfo P-PP , PP-SP

func ReqGetHDInfo

func ReqGetHDInfo(ctx context.Context, conn core.WriteCloser)

func ReqGetPPDowngradeInfo added in v0.9.0

func ReqGetPPDowngradeInfo(ctx context.Context) error

func ReqGetWalletOzForDownload added in v0.10.0

func ReqGetWalletOzForDownload(ctx context.Context, walletAddr, reqId string, downloadReq *protos.ReqFileStorageInfo) error

func ReqGetWalletOzForUpload added in v0.10.0

func ReqGetWalletOzForUpload(ctx context.Context, walletAddr, reqId string, uploadReq *protos.ReqUploadFile) error

func ReqPpLatencyCheck added in v0.10.0

func ReqPpLatencyCheck(ctx context.Context, conn core.WriteCloser)

ReqPpLatencyCheck Request latency measurement to a pp

func ReqTransferDownload

func ReqTransferDownload(ctx context.Context, conn core.WriteCloser)

ReqTransferDownload Another PP wants to download a slice from the current PP

func ReqUploadFileSlice

func ReqUploadFileSlice(ctx context.Context, conn core.WriteCloser)

ReqUploadFileSlice storage PP receives a request with file data from the PP who initiated uploading

func RequestUploadFile

func RequestUploadFile(ctx context.Context, path string, isEncrypted, isVideoStream bool, desiredTier uint32, allowHigherTier bool,
	walletAddr string, walletPubkey, wsign []byte)

RequestUploadFile request to SP for upload file

func RspActivate

func RspActivate(ctx context.Context, conn core.WriteCloser)

RspActivate Response to asking the SP node to activate this PP node

func RspBackupFileSlice added in v0.10.0

func RspBackupFileSlice(ctx context.Context, conn core.WriteCloser)

func RspBackupStatus added in v0.8.0

func RspBackupStatus(ctx context.Context, _ core.WriteCloser)

func RspBackupStatusVerifier added in v0.10.0

func RspBackupStatusVerifier(ctx context.Context, msgType header.MsgType, target interface{}) error

RspBackupStatusVerifier task level verifier for all messages carrying RspBackupStatus in a backup task

func RspBackupStatusWithNoReqIdVerifier added in v0.10.0

func RspBackupStatusWithNoReqIdVerifier(ctx context.Context, msgType header.MsgType, target interface{}) error

RspBackupStatusWithNoReqIdVerifier no reqid verification for a request message from gateway pp

func RspBadVersion added in v0.7.0

func RspBadVersion(ctx context.Context, _ core.WriteCloser)
func RspClearExpiredShareLinks(ctx context.Context, conn core.WriteCloser)

func RspDeactivate

func RspDeactivate(ctx context.Context, conn core.WriteCloser)

RspDeactivate Response to asking the SP node to deactivate this PP node

func RspDeleteFile

func RspDeleteFile(ctx context.Context, conn core.WriteCloser)

func RspDeleteShare

func RspDeleteShare(ctx context.Context, conn core.WriteCloser)

func RspDownloadFileWrong added in v0.7.0

func RspDownloadFileWrong(ctx context.Context, conn core.WriteCloser)

RspFileStorageInfo SP-PP , PP-P

func RspDownloadSlice

func RspDownloadSlice(ctx context.Context, conn core.WriteCloser)

RspDownloadSlice storagePP-PP

func RspFileReplicaInfo added in v0.10.0

func RspFileReplicaInfo(ctx context.Context, conn core.WriteCloser)

func RspFileStatus added in v0.10.0

func RspFileStatus(ctx context.Context, conn core.WriteCloser)

func RspFileStorageInfo

func RspFileStorageInfo(ctx context.Context, conn core.WriteCloser)

RspFileStorageInfo SP-PP , PP-P

func RspFileStorageInfoVerifier added in v0.10.0

func RspFileStorageInfoVerifier(ctx context.Context, msgType header.MsgType, target interface{}) error

RspFileStorageInfoVerifier task level verifier for all messages carrying RspFileStorageInfo in a download task

func RspFileStorageInfoWithNoReqIdVerifier added in v0.10.0

func RspFileStorageInfoWithNoReqIdVerifier(ctx context.Context, msgType header.MsgType, target interface{}) error

RspFileStorageInfoWithNoReqIdVerifier no reqid verification for a request message from gateway pp

func RspFindMyFileList

func RspFindMyFileList(ctx context.Context, conn core.WriteCloser)

func RspGetHDInfo

func RspGetHDInfo(ctx context.Context, conn core.WriteCloser)

func RspGetPPDowngradeInfo added in v0.9.0

func RspGetPPDowngradeInfo(ctx context.Context, conn core.WriteCloser)

RspGetPPDowngradeInfo

func RspGetPPList

func RspGetPPList(ctx context.Context, conn core.WriteCloser)

func RspGetPPStatus added in v0.5.1

func RspGetPPStatus(ctx context.Context, conn core.WriteCloser)

RspGetPPStatus

func RspGetSPList

func RspGetSPList(ctx context.Context, conn core.WriteCloser)

func RspGetShareFile

func RspGetShareFile(ctx context.Context, _ core.WriteCloser)

func RspGetWalletOz added in v0.6.0

func RspGetWalletOz(ctx context.Context, conn core.WriteCloser)

func RspMining

func RspMining(ctx context.Context, conn core.WriteCloser)

RspMining RspMining

func RspPpLatencyCheck added in v0.10.0

func RspPpLatencyCheck(ctx context.Context, _ core.WriteCloser)

func RspPrepay

func RspPrepay(ctx context.Context, conn core.WriteCloser)

RspPrepay Response to asking the SP node to send a prepay transaction

func RspRegister

func RspRegister(ctx context.Context, conn core.WriteCloser)

RspRegister PP -> SP, SP -> PP, PP -> P

func RspRegisterNewPP

func RspRegisterNewPP(ctx context.Context, conn core.WriteCloser)

RspRegisterNewPP SP-P

func RspReportBackupSliceResult added in v0.5.0

func RspReportBackupSliceResult(ctx context.Context, conn core.WriteCloser)

RspReportBackupSliceResult

func RspReportDownloadResult

func RspReportDownloadResult(ctx context.Context, conn core.WriteCloser)

RspReportDownloadResult SP-P OR SP-PP

func RspReportNodeStatus added in v0.7.0

func RspReportNodeStatus(ctx context.Context, conn core.WriteCloser)

RspReportNodeStatus

func RspReportUploadSliceResult

func RspReportUploadSliceResult(ctx context.Context, conn core.WriteCloser)

RspReportUploadSliceResult SP-P OR SP-PP

func RspShareFile

func RspShareFile(ctx context.Context, conn core.WriteCloser)
func RspShareLink(ctx context.Context, conn core.WriteCloser)

func RspSpLatencyCheck added in v0.10.0

func RspSpLatencyCheck(ctx context.Context, _ core.WriteCloser)

RspSpLatencyCheck message RspSpLatencyCheck's handler

func RspStartMaintenance added in v0.9.0

func RspStartMaintenance(ctx context.Context, _ core.WriteCloser)

func RspStateChange added in v0.10.0

func RspStateChange(ctx context.Context, conn core.WriteCloser)

func RspStopMaintenance added in v0.9.0

func RspStopMaintenance(ctx context.Context, _ core.WriteCloser)

func RspTransferDownload

func RspTransferDownload(ctx context.Context, conn core.WriteCloser)

RspTransferDownload The receiver PP gets this response from the uploader PP

func RspTransferDownloadResult

func RspTransferDownloadResult(ctx context.Context, conn core.WriteCloser)

RspTransferDownloadResult The receiver PP sends this msg when the download is finished. If successful, we can report the result and delete the file

func RspUpdateDeposit added in v0.10.0

func RspUpdateDeposit(ctx context.Context, conn core.WriteCloser)

RspUpdateDeposit Response to asking the SP node to update deposit this node

func RspUploadFile

func RspUploadFile(ctx context.Context, _ core.WriteCloser)

RspUploadFile response of upload file event, SP -> upgrader, upgrader -> dest PP

func RspUploadFileSlice

func RspUploadFileSlice(ctx context.Context, conn core.WriteCloser)

func RspUploadFileVerifier added in v0.10.0

func RspUploadFileVerifier(ctx context.Context, msgType header.MsgType, target interface{}) error

RspUploadFileVerifier task level verifier for all messages carrying RspUploadFile in a uploading task

func RspUploadFileWithNoReqIdVerifier added in v0.10.0

func RspUploadFileWithNoReqIdVerifier(ctx context.Context, msgType header.MsgType, target interface{}) error

RspUploadFileWithNoReqIdVerifier no reqid verification for a request message from gateway pp

func RspUploadSlicesWrong added in v0.9.0

func RspUploadSlicesWrong(ctx context.Context, _ core.WriteCloser)

RspUploadSlicesWrong updates the destination of slices for an ongoing upload

func ScheduleReqBackupStatus added in v0.8.0

func ScheduleReqBackupStatus(ctx context.Context, fileHash string)

func SendReportBackupSliceResult added in v0.5.0

func SendReportBackupSliceResult(ctx context.Context, taskId, sliceHash, spP2pAddress string, result bool, originDeleted bool, costTime int64)

func SendReportDownloadResult

func SendReportDownloadResult(ctx context.Context, target *protos.RspDownloadSlice, costTime int64, isPP bool) *protos.ReqReportDownloadResult

SendReportDownloadResult PP-SP OR StoragePP-SP

func SendReportStreamingResult

func SendReportStreamingResult(ctx context.Context, target *protos.RspDownloadSlice, isPP bool)

SendReportStreamingResult P-SP OR PP-SP

func SendReqDownloadSlice

func SendReqDownloadSlice(ctx context.Context, fileHash string, sliceInfo *protos.DownloadSliceInfo, req *protos.ReqDownloadSlice, fileReqId string)

func SpAddressVerifier added in v0.10.0

func SpAddressVerifier(ctx context.Context, msgType header.MsgType, target interface{}) error

func SpRspVerifier added in v0.10.0

func SpRspVerifier(ctx context.Context, msgType header.MsgType, target interface{}) error

func StartMaintenance added in v0.9.0

func StartMaintenance(ctx context.Context, duration uint64) error

StartMaintenance sends a request to SP to temporarily put the current node into maintenance mode

func StartReportTransferFailureJob added in v0.11.0

func StartReportTransferFailureJob(ctx context.Context)

func StopMaintenance added in v0.9.0

func StopMaintenance(ctx context.Context) error

func StopReportTransferFailureJob added in v0.11.0

func StopReportTransferFailureJob()

func UpdateDeposit added in v0.10.0

func UpdateDeposit(ctx context.Context, depositDelta utiltypes.Coin, txFee utiltypes.TxFee) error

UpdateDeposit Update deposit of node

func UploadFileSlice

func UploadFileSlice(ctx context.Context, tk *task.UploadSliceTask) error

func UploadPause

func UploadPause(ctx context.Context, fileHash, reqID string, w http.ResponseWriter)

func UploadSpeedOfProgress

func UploadSpeedOfProgress(ctx context.Context, _ core.WriteCloser)

func VerifyMessage added in v0.10.0

func VerifyMessage(ctx context.Context, msgType header.MsgType, target interface{}) error

Types

type CostTimeStat added in v0.9.0

type CostTimeStat struct {
	TotalCostTime int64
	PacketCount   int64
}

type DownloadTimeoutHandler added in v0.7.0

type DownloadTimeoutHandler struct {
}

func (*DownloadTimeoutHandler) CanDelete added in v0.7.0

func (handler *DownloadTimeoutHandler) CanDelete(rspMessage *msg.RelayMsgBuf) bool

func (*DownloadTimeoutHandler) GetDuration added in v0.7.0

func (handler *DownloadTimeoutHandler) GetDuration() time.Duration

func (*DownloadTimeoutHandler) GetTimeoutMsg added in v0.7.0

func (handler *DownloadTimeoutHandler) GetTimeoutMsg(reqMessage *msg.RelayMsgBuf) *msg.RelayMsgBuf

func (*DownloadTimeoutHandler) Handle added in v0.7.0

func (handler *DownloadTimeoutHandler) Handle(ctx context.Context, message *msg.RelayMsgBuf)

type QueuedDownloadReportToSP added in v0.9.0

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

type TaskSlice added in v0.9.0

type TaskSlice struct {
	TkSliceUID string
	SliceType  int32

	TaskId        string
	SliceHash     string
	SpP2pAddress  string
	OriginDeleted bool
	// contains filtered or unexported fields
}

type UploadFileHandler added in v0.10.0

type UploadFileHandler interface {
	PreUpload(ctx context.Context, filePath, encryptionTag string) (*protos.FileInfo, []*protos.SliceHashAddr, error)
}

func GetUploadFileHandler added in v0.10.0

func GetUploadFileHandler(isVideoStream bool) UploadFileHandler

type UploadRawFileHandler added in v0.10.0

type UploadRawFileHandler struct {
}

func (UploadRawFileHandler) PreUpload added in v0.10.0

func (UploadRawFileHandler) PreUpload(ctx context.Context, filePath, encryptionTag string) (*protos.FileInfo, []*protos.SliceHashAddr, error)

type UploadStreamFileHandler added in v0.10.0

type UploadStreamFileHandler struct {
}

func (UploadStreamFileHandler) PreUpload added in v0.10.0

func (UploadStreamFileHandler) PreUpload(ctx context.Context, filePath, encryptionTag string) (*protos.FileInfo, []*protos.SliceHashAddr, error)

type VerifierFunc added in v0.10.0

type VerifierFunc func(context.Context, header.MsgType, interface{}) error

Jump to

Keyboard shortcuts

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