Documentation
¶
Index ¶
- func CreateTempFile(payload []byte) (file *os.File, err error)
- func HandleFileUploadRequestPubSub(p2p *dep2p.DeP2P, pubsub *pubsub.DeP2PPubSub, res *streams.RequestMessage)
- func HandleFileUploadResponsePubSub(p2p *dep2p.DeP2P, pubsub *pubsub.DeP2PPubSub, pool *pool.MemoryPool, ...)
- func RegisterFileSliceUploadEvent(opt *opts.Options, p2p *dep2p.DeP2P, pubsub *pubsub.DeP2PPubSub, ...) error
- func RegisterFileUploadCheckEvent(p2p *dep2p.DeP2P, pubsub *pubsub.DeP2PPubSub, db *sqlites.SqliteDB, ...) error
- func SendFileSliceToNetwork(opt *opts.Options, p2p *dep2p.DeP2P, uploadChan chan *core.UploadChan, ...) error
- func SendStorageInfo(storageChans chan *core.StorageChan, fileID, sliceHash string, ...)
- func SendUploadInfo(uploadChans chan *core.UploadChan, fileID, sliceHash string, ...)
- func Upload(ctx context.Context, opt *opts.Options, db *sqlites.SqliteDB, ...) (..., error)
- type FileUploadRequestCheckPayload
- type StreamProtocol
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandleFileUploadRequestPubSub ¶
func HandleFileUploadRequestPubSub(p2p *dep2p.DeP2P, pubsub *pubsub.DeP2PPubSub, res *streams.RequestMessage)
HandleFileUploadRequestPubSub 处理文件上传请求的订阅消息
func HandleFileUploadResponsePubSub ¶
func HandleFileUploadResponsePubSub(p2p *dep2p.DeP2P, pubsub *pubsub.DeP2PPubSub, pool *pool.MemoryPool, res *streams.RequestMessage)
HandleFileUploadResponsePubSub 处理文件上传响应的订阅消息
func RegisterFileSliceUploadEvent ¶
func RegisterFileSliceUploadEvent( opt *opts.Options, p2p *dep2p.DeP2P, pubsub *pubsub.DeP2PPubSub, db *sqlites.SqliteDB, uploadChan chan *core.UploadChan, registry *eventbus.EventRegistry, cache *ristretto.Cache, pool *pool.MemoryPool, ) error
registerFileSliceUploadEvent 注册文件片段上传事件
func RegisterFileUploadCheckEvent ¶
func RegisterFileUploadCheckEvent( p2p *dep2p.DeP2P, pubsub *pubsub.DeP2PPubSub, db *sqlites.SqliteDB, registry *eventbus.EventRegistry, pool *pool.MemoryPool, ) error
registerFileUploadCheckEvent 注册文件上传检查事件
func SendFileSliceToNetwork ¶
func SendFileSliceToNetwork(opt *opts.Options, p2p *dep2p.DeP2P, uploadChan chan *core.UploadChan, registry *eventbus.EventRegistry, cache *ristretto.Cache, pm *pool.MemoryPool, fileID, sliceHash string, totalPieces, current int) error
SendFileSliceToNetwork 发送文件片段至网络 fileID 文件的唯一标识(外部标识) sliceHash 文件片段的哈希值(外部标识) totalPieces 文件片段的总量 current 当前序列
func SendStorageInfo ¶ added in v0.0.9
func SendStorageInfo(storageChans chan *core.StorageChan, fileID, sliceHash string, totalPieces, index int, peerIDs string)
SendStorageInfo 向存储奖励通道发送信息
func SendUploadInfo ¶
func SendUploadInfo(uploadChans chan *core.UploadChan, fileID, sliceHash string, totalPieces, index int, peerIDs []string)
SendUploadInfo 向上传通道发送信息
func Upload ¶
func Upload( ctx context.Context, opt *opts.Options, db *sqlites.SqliteDB, registry *eventbus.EventRegistry, cache *ristretto.Cache, pool *pool.MemoryPool, path string, ownerPriv *ecdsa.PrivateKey, ) (*struct { FileID string // 文件的唯一标识 FileKey string // 文件的密钥 Name string // 文件的名称 Size int64 // 文件的长度(以字节为单位) UploadTime time.Time // 上传时间 ModTime time.Time // 修改时间 FileType string // 文件类型或格式 }, error)
Upload 上传新文件
Types ¶
type FileUploadRequestCheckPayload ¶
type FileUploadRequestCheckPayload struct {
FileID string // 文件的唯一标识(外部标识)
UploadTime time.Time // 上传时间
}
文件上传请求(检查)
type StreamProtocol ¶
type StreamProtocol struct {
Ctx context.Context // 全局上下文
Opt *opts.Options // 文件存储选项配置
P2P *dep2p.DeP2P // DeP2P网络主机
PubSub *pubsub.DeP2PPubSub // DeP2P网络订阅
DB *sqlites.SqliteDB // sqlite数据库服务
UploadChan chan *core.UploadChan // 用于刷新上传的通道
DownloadChan chan *core.DownloadChan // 用于刷新下载的通道
StorageChan chan *core.StorageChan // 用于存储奖励的通知
Registry *eventbus.EventRegistry // 事件总线
Cache *ristretto.Cache // 缓存实例
Pool *pool.MemoryPool // 内存池
}
流协议
func (*StreamProtocol) HandleStreamFileSliceUploadStream ¶
func (sp *StreamProtocol) HandleStreamFileSliceUploadStream(req *streams.RequestMessage, res *streams.ResponseMessage) error
HandleStreamFileSliceUploadStream 处理文件片段上传的流消息
Click to show internal directories.
Click to hide internal directories.