node

package
v0.5.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	C_Filler     chan Filler
	C_FillerMeta chan chain.FillerMetaInfo
	FillerMap    *Fillermetamap
)
View Source
var (
	MAGIC_BYTES = []byte("cess")
	EmErr       = fmt.Errorf("dont have msg")
)
View Source
var (
	BytesPool = sync.Pool{
		New: func() any {
			return make([]byte, 40*1024)
		},
	}
)

Functions

func CalcFileBlockSizeAndScanSize

func CalcFileBlockSizeAndScanSize(fsize int64) (int64, int64)

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(fid string, pkey, signmsg, sign []byte) error
}

type ConMgr

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

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 {
	MsgType  MsgType `json:"msg_type"`
	FileName string  `json:"file_name"`
	FileHash string  `json:"file_hash"`
	FileSize uint64  `json:"file_size"`
	LastMark bool    `json:"last_mark"`
	Pubkey   []byte  `json:"pub_key"`
	SignMsg  []byte  `json:"sign_msg"`
	Sign     []byte  `json:"sign"`
	Bytes    []byte  `json:"bytes"`
}

func Decode

func Decode(b []byte) (m *Message, err error)

Decode will convert from bytes

func NewCloseMsg

func NewCloseMsg(fileName string, status Status) *Message

func NewEndMsg

func NewEndMsg(fileName string, size uint64, lastmark bool) *Message

func NewFileMsg

func NewFileMsg(fileName string, buf []byte) *Message

func NewFillerEndMsg

func NewFillerEndMsg(fileName string, size uint64) *Message

func NewFillerMsg

func NewFillerMsg(fileName string, buf []byte) *Message

func NewHeadMsg

func NewHeadMsg(fileName string, fid string, lastmark bool, pkey, signmsg, sign []byte) *Message

func NewNotifyFillerMsg

func NewNotifyFillerMsg(fileName string, status Status) *Message

func NewNotifyMsg

func NewNotifyMsg(fileName string, status Status) *Message

func (*Message) GC

func (m *Message) GC()

func (*Message) String

func (m *Message) String() string

type MsgType

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

type NetConn

type NetConn interface {
	HandlerLoop()
	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
	Conn    *ConMgr

	FileDir   string
	TagDir    string
	FillerDir string
	// contains filtered or unexported fields
}

func New

func New() *Node

New is used to build a node instance

func (*Node) AddConns

func (n *Node) AddConns()

AddConns is used to add a connection number record

func (*Node) ClearConns

func (n *Node) ClearConns()

ClearConns is used to clear a connection number record

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) GetConns

func (n *Node) GetConns() uint8

ClearConns is used to clear a connection number record

func (*Node) InitLock

func (n *Node) InitLock()

InitLock is used to initialize lock

func (*Node) NewClient

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

func (*Node) NewServer

func (n *Node) NewServer(conn NetConn) Server

func (*Node) Run

func (n *Node) Run()

func (*Node) SendFile

func (n *Node) SendFile(fid string, pkey, signmsg, sign []byte) error

func (*Node) Start

func (n *Node) Start()

type Notify

type Notify struct {
	Status byte
}

type Scheduler

type Scheduler interface {
	Run()
}

type Server

type Server interface {
	Start()
}

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()

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