node

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2022 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FileType_Invalid uint8 = iota
	FileType_file
	FileType_filler
)

Variables

View Source
var (
	C_Filler     chan Filler
	C_FillerMeta chan chain.FillerMetaInfo
	FillerMap    *Fillermetamap
)
View Source
var (
	HEAD_FILE   = []byte("c100")
	HEAD_FILLER = []byte("c101")
)

Functions

func CalcFileBlockSizeAndScanSize

func CalcFileBlockSizeAndScanSize(fsize int64) (int64, int64)

func ConnectionFiltering added in v0.5.3

func ConnectionFiltering(conn *net.TCPConn) bool

func GetFileState

func GetFileState(c chain.Chainer, fileHash string) (string, error)

func VerifySign

func VerifySign(pkey, signmsg, sign []byte) (bool, error)

Types

type Client

type Client interface {
	SendFile(node *Node, fid string, filetype uint8, pkey, signmsg, sign []byte) error
}

func NewClient added in v0.5.3

func NewClient(conn NetConn, dir string, files []string) Client

type ConMgr

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

func (*ConMgr) SendFile added in v0.5.3

func (c *ConMgr) SendFile(node *Node, fid string, filetype uint8, pkey, signmsg, sign []byte) error

func (*ConMgr) Start added in v0.5.3

func (c *ConMgr) Start(node *Node)

type Filler

type Filler struct {
	Hash       string
	FillerPath string
	TagPath    string
}

type Fillermetamap

type Fillermetamap struct {
	Fillermetas map[string][]chain.FillerMetaInfo
	// contains filtered or unexported fields
}

func (*Fillermetamap) Add

func (this *Fillermetamap) Add(pubkey string, data chain.FillerMetaInfo)

func (*Fillermetamap) Delete

func (this *Fillermetamap) Delete(pubkey string)

func (*Fillermetamap) GetNum

func (this *Fillermetamap) GetNum(pubkey string) int

type Message

type Message struct {
	Pubkey   []byte  `json:"pubkey"`
	SignMsg  []byte  `json:"signmsg"`
	Sign     []byte  `json:"sign"`
	Bytes    []byte  `json:"bytes"`
	FileName string  `json:"filename"`
	FileHash string  `json:"filehash"`
	FileSize uint64  `json:"filesize"`
	MsgType  MsgType `json:"msgtype"`
	LastMark bool    `json:"lastmark"`
	FileType uint8   `json:"filetype"`
}

type MsgType

type MsgType byte
const (
	MsgInvalid MsgType = iota
	MsgHead
	MsgFile
	MsgEnd
	MsgNotify
	MsgClose
	MsgRecvHead
	MsgRecvFile
)

type NetConn

type NetConn interface {
	HandlerLoop(flag bool)
	GetMsg() (*Message, bool)
	SendMsg(m *Message)
	GetRemoteAddr() string
	Close() error
	IsClose() bool
}

type Node

type Node struct {
	Confile   confile.Confiler
	Chain     chain.Chainer
	Logs      logger.Logger
	Cache     db.Cacher
	FileDir   string
	TagDir    string
	FillerDir string
}

func New

func New() *Node

New is used to build a node instance

func (*Node) CoroutineMgr

func (node *Node) CoroutineMgr()

CoroutineMgr is the management program of the cooperation program, which can start the cooperation program that unexpectedly exits.

func (*Node) FileBackupManagement

func (n *Node) FileBackupManagement(fid string, fsize int64, chunks []string)

file backup management

func (*Node) Run

func (n *Node) Run()

type Notify

type Notify struct {
	Status byte
}

type Scheduler

type Scheduler interface {
	Run()
}

type Server

type Server interface {
	Start(node *Node)
}

func NewServer added in v0.5.3

func NewServer(conn NetConn, dir string) Server

type Status

type Status byte
const (
	Status_Ok Status = iota
	Status_Err
)

type TagInfo

type TagInfo struct {
	T      pbc.FileTagT
	Sigmas [][]byte `json:"sigmas"`
}

type TcpCon

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

func NewTcp

func NewTcp(conn *net.TCPConn) *TcpCon

func (*TcpCon) Close

func (t *TcpCon) Close() error

func (*TcpCon) GetMsg

func (t *TcpCon) GetMsg() (*Message, bool)

func (*TcpCon) GetRemoteAddr

func (t *TcpCon) GetRemoteAddr() string

func (*TcpCon) HandlerLoop

func (t *TcpCon) HandlerLoop(flag bool)

func (*TcpCon) IsClose

func (t *TcpCon) IsClose() bool

func (*TcpCon) SendMsg

func (t *TcpCon) SendMsg(m *Message)

Jump to

Keyboard shortcuts

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