node

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: Apache-2.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HTTPHeader_Authorization = "Authorization"
	HTTPHeader_BucketName    = "BucketName"
	HTTPHeader_Account       = "Account"
	HTTPHeader_EthAccount    = "EthAcc"
	HTTPHeader_Digest        = "Digest"
	HTTPHeader_Operation     = "Operation"
	HTTPHeader_Message       = "Message"
	HTTPHeader_Signature     = "Signature"
	HTTPHeader_Fid           = "Fid"
	HTTPHeader_Cipher        = "cipher"
)

HTTP HEADER

View Source
const (
	Active = iota
	Calculate
	Missing
	Recovery
)
View Source
const (
	HTTP_ParameterName = "name"
	FormFileKey1       = "file"
	FormFileKey2       = "File"
	FormFileKey3       = "FILE"
)
View Source
const (
	INFO_PutRequest         = "PutRequest"
	INFO_PostRestoreRequest = "PostRestoreRequest"
	INFO_GetRequest         = "GetRequest"
	INFO_GetRestoreRequest  = "GetRestoreRequest"
	INFO_DelRequest         = "DelRequest"

	ERR_DuplicateOrder        = "duplicate order"
	ERR_MissToken             = "InvalidHead.MissToken"
	ERR_EmptySeed             = "InvalidProfile.EmptySeed"
	ERR_MissingAccount        = "InvalidHead.MissingAccount"
	ERR_InvalidAccount        = "InvalidHead.Account"
	ERR_NoPermission          = "InvalidToken.NoPermission"
	ERR_InvalidToken          = "InvalidHead.Token"
	ERR_InvalidName           = "InvalidParameter.Name"
	ERR_InvalidFilehash       = "InvalidParameter.FileHash"
	ERR_InvalidParaBucketName = "InvalidParameter.BucketName"
	ERR_InvalidBucketName     = "InvalidHead.BucketName"
	ERR_EmptyBucketName       = "Invalid.EmptyBucketName"
	ERR_UnauthorizedSpace     = "UnauthorizedSpace"
	ERR_EmptyFile             = "InvalidBody.EmptyFile"
	ERR_ReadBody              = "InvalidBody.ReadErr"
	ERR_ParseBody             = "InvalidBody.ParseErr"
	//ERR_SpaceExpired          = "space expired"
	ERR_NotEnoughSpace = "not enough account space"

	ERR_InternalServer  = "InternalError"
	ERR_FileNameTooLang = "The file name length cannot exceed 63 characters"
	ERR_NoSpace         = "please purchase space first"
)
View Source
const (
	ERR_Authorization = "HeaderErr_Invalid_Authorization"

	ERR_HeadOperation = "HeaderErr_Invalid_Operation"

	ERR_NotFound  = "Not found"
	ERR_Forbidden = "no permission"

	ERR_BodyFormat         = "BodyErr_InvalidDataFormat"
	ERR_BodyFieldAccount   = "BodyErr_InvalidField_account"
	ERR_BodyFieldMessage   = "BodyErr_InvalidField_message"
	ERR_BodyFieldSignature = "BodyErr_InvalidField_signature"
	ERR_BodyEmptyFile      = "BodyErr_EmptyFile"

	ERR_HeaderFieldBucketName = "HeaderErr_InvalidBucketName"

	ERR_AccountNotExist   = "account does not exist"
	ERR_RpcFailed         = "rpc connection failed"
	ERR_SpaceExpiresSoon  = "space expires soon"
	ERR_SpaceNotAuth      = "space is not authorized"
	ERR_DeviceSpaceNoLeft = "no space left on the server device"

	ERR_SysMemNoLeft = "server unsupported file size"

	ERR_ReceiveFile = "InternalError"
)
View Source
const (
	Cache_SyncBlock       = "syncblock"
	Cache_UserFiles       = "userfiles:"
	Cache_UserDeleteFiles = "userdeletefiles:"
	Cache_WantFiles       = "wantfiles:"
)
View Source
const MaxMemUsed = 512 << 20
View Source
const MinRecordInfoLength = 132

MinRecordInfoLength = len(json.Marshal(RecordInfo{}))

View Source
const TokenDated = 60 * 60 * 24 * 30

Variables

This section is empty.

Functions

func VerifyEthSign added in v0.3.6

func VerifyEthSign(message string, sign string) (string, error)

Types

type DelList

type DelList struct {
	Files []string `json:"files"`
}

type FileMetaData

type FileMetaData struct {
	Completion  uint32
	State       string
	SegmentList []SegmentInfo
	Owner       []RtnUserBrief
}

file meta info

type FragmentInfo

type FragmentInfo struct {
	FragmentHash string
	Avail        bool
	Miner        string
}

type Node

type Node struct {
	inter.TrackFile
	confile.Confile
	logger.Logger
	db.Cache
	sdk.SDK
	core.P2P
	*gin.Engine
	// contains filtered or unexported fields
}

func New

func New() *Node

New is used to build a node instance

func (*Node) AccessControl added in v0.3.3

func (n *Node) AccessControl(account string) error

func (*Node) AddToBlacklist added in v0.3.0

func (n *Node) AddToBlacklist(peerid string)

func (*Node) DelFromBlacklist added in v0.3.0

func (n *Node) DelFromBlacklist(peerid string)

func (*Node) DeleteStoragePeer added in v0.3.3

func (n *Node) DeleteStoragePeer(peerid string)

func (*Node) DeleteTrackFile

func (n *Node) DeleteTrackFile(filehash string)

func (*Node) EncodePeers added in v0.2.5

func (n *Node) EncodePeers() []byte

func (*Node) GetAllPeerId added in v0.2.1

func (n *Node) GetAllPeerId() []string

func (*Node) GetAllStoragePeerId added in v0.3.3

func (n *Node) GetAllStoragePeerId() []string

func (*Node) GetPeer

func (n *Node) GetPeer(peerid string) (peer.AddrInfo, bool)

func (*Node) HasBlacklist added in v0.3.0

func (n *Node) HasBlacklist(peerid string) (int64, bool)

func (*Node) HasPeer

func (n *Node) HasPeer(peerid string) bool

func (*Node) HasStoragePeer added in v0.3.3

func (n *Node) HasStoragePeer(peerid string) bool

func (*Node) HasTrackFile

func (n *Node) HasTrackFile(filehash string) bool

func (*Node) ListTrackFiles

func (n *Node) ListTrackFiles() ([]string, error)

func (*Node) LoadPeersFromDisk added in v0.2.4

func (n *Node) LoadPeersFromDisk(path string) error

func (*Node) ParseTrackFile added in v0.3.3

func (n *Node) ParseTrackFile(filehash string) (RecordInfo, error)

func (*Node) RebuildDirs

func (n *Node) RebuildDirs()

func (*Node) RemovePeerIntranetAddr added in v0.2.5

func (n *Node) RemovePeerIntranetAddr()

func (*Node) Run

func (n *Node) Run()

func (*Node) Run2 added in v0.3.6

func (n *Node) Run2(port int, workspace string)

func (*Node) SaveOrUpdatePeerUnSafe added in v0.2.5

func (n *Node) SaveOrUpdatePeerUnSafe(peerid string, addr peer.AddrInfo)

func (*Node) SavePeer

func (n *Node) SavePeer(peerid string, addr peer.AddrInfo)

func (*Node) SavePeersToDisk added in v0.2.4

func (n *Node) SavePeersToDisk(path string) error

func (*Node) SaveStoragePeer added in v0.3.3

func (n *Node) SaveStoragePeer(peerid string)

func (*Node) SetDfileDir added in v0.3.2

func (n *Node) SetDfileDir(dir string)

func (*Node) SetFadebackDir added in v0.3.1

func (n *Node) SetFadebackDir(dir string)

func (*Node) SetSignkey

func (n *Node) SetSignkey(signkey []byte)

func (*Node) SetTrackDir added in v0.2.4

func (n *Node) SetTrackDir(dir string)

func (*Node) SetUfileDir added in v0.3.2

func (n *Node) SetUfileDir(dir string)

func (*Node) TaskMgt

func (n *Node) TaskMgt()

func (*Node) VerifyAccountSignature added in v0.3.6

func (n *Node) VerifyAccountSignature(account, msg, signature string) ([]byte, error)

func (*Node) WriteTrackFile

func (n *Node) WriteTrackFile(filehash string, data []byte) error

type Oss

type Oss interface {
	Run()
}

type RecordInfo

type RecordInfo struct {
	SegmentInfo []pattern.SegmentDataInfo `json:"segmentInfo"`
	Owner       []byte                    `json:"owner"`
	Roothash    string                    `json:"roothash"`
	Filename    string                    `json:"filename"`
	Buckname    string                    `json:"buckname"`
	Filesize    uint64                    `json:"filesize"`
	Putflag     bool                      `json:"putflag"`
	Count       uint8                     `json:"count"`
	Duplicate   bool                      `json:"duplicate"`
}

type RestoreList added in v0.3.2

type RestoreList struct {
	Files []string `json:"files"`
}

type RtnBlockInfo

type RtnBlockInfo struct {
	MinerId  uint64
	BlockId  string
	MinerIp  string
	MinerAcc string
}

file block info

type RtnFileType

type RtnFileType struct {
	FileSize   uint64
	FileState  string
	UserBriefs []RtnUserBrief
	BlockInfo  []RtnBlockInfo
}

type RtnUserBrief

type RtnUserBrief struct {
	User       string
	FileName   string
	BucketName string
}

type SegmentInfo

type SegmentInfo struct {
	SegmentHash  string
	FragmentList []FragmentInfo
}

Jump to

Keyboard shortcuts

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