upload

package
v1.1.9 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2021 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const LOCALDIR = "./blocks/" // Local directory to store temp blocks files

Variables

This section is empty.

Functions

func AddInterval

func AddInterval(end, gzSize uint64) error

AddInterval if "info.json" exists on OSS, add Interval to the end; if not exist, create "info.json" with Interval

func LoadConfig

func LoadConfig(config interface{}) error

LoadConfig read path file to the config object for Upload from Vapor to OSS

func LoadConfigByPath

func LoadConfigByPath(path string, config interface{}) error

LoadConfigByPath read path file to the config object

func Run

func Run() error

Run synchronize upload blocks from vapor to OSS

Types

type Config

type Config struct {
	OssConfig *OssConfig `json:"oss_config"`
	VaporURL  string     `json:"vapor_url"`
}

Config represent root of config

type Login

type Login struct {
	Endpoint        string `json:"endpoint"`
	AccessKeyID     string `json:"access_key_id"`
	AccessKeySecret string `json:"access_key_secret"`
}

Oss logs cfg

type OssConfig

type OssConfig struct {
	Login     *Login `json:"login"`
	Bucket    string `json:"bucket"`
	Directory string `json:"directory"`
}

Oss cfg

type UploadKeeper

type UploadKeeper struct {
	Node      *apinode.Node
	OssClient *oss.Client
	OssBucket *oss.Bucket
	OssDir    string
	FileUtil  *util.FileUtil
}

UploadKeeper the struct for upload

func NewUploadKeeper

func NewUploadKeeper() (*UploadKeeper, error)

NewUploadKeeper return one new instance of UploadKeeper

func (*UploadKeeper) AddInterval

func (u *UploadKeeper) AddInterval(end, gzSize uint64) error

AddInterval if "info.json" exists on OSS, add Interval to the end; if not exist, create "info.json" with Interval

func (*UploadKeeper) GetBlockArray

func (u *UploadKeeper) GetBlockArray(start, length uint64) ([]*types.Block, error)

GetBlockArray return the RawBlockArray by BlockHeight from start to start+length-1

func (*UploadKeeper) GetInfoJson

func (u *UploadKeeper) GetInfoJson() (*util.Info, error)

GetInfoJson Download info.json

func (*UploadKeeper) PutInfoJson

func (u *UploadKeeper) PutInfoJson(infoData *util.Info) error

Upload info.json

func (*UploadKeeper) PutObjByteArr

func (u *UploadKeeper) PutObjByteArr(objectName string, objectValue []byte) error

PutObjByteArr upload Byte Array object

func (*UploadKeeper) Run

func (u *UploadKeeper) Run()

Run synchronize upload blocks from vapor to OSS

func (*UploadKeeper) SetLatestBlockHeight

func (u *UploadKeeper) SetLatestBlockHeight(newLatestBlockHeight uint64) error

SetLatestBlockHeight set new latest blockHeight on OSS

func (*UploadKeeper) Upload

func (u *UploadKeeper) Upload() error

Upload find and upload blocks

func (*UploadKeeper) UploadFiles

func (u *UploadKeeper) UploadFiles(start, end, size uint64) error

UploadFiles get block from vapor and upload files to OSS

Jump to

Keyboard shortcuts

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