node

package
v0.7.16 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2024 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Active = iota
	Calculate
	Missing
	Recovery
)
View Source
const (
	// Record the fid of stored files
	Cach_prefix_File = "file:"
	// Record the block of reported tags
	Cach_prefix_Tag = "tag:"

	Cach_prefix_MyLost      = "mylost:"
	Cach_prefix_recovery    = "recovery:"
	Cach_prefix_TargetMiner = "targetminer:"
	Cach_prefix_ParseBlock  = "parseblocks"
)
View Source
const (
	Success            = 200
	Error              = 201
	ErrorParam         = 202
	ErrorParamNotFound = 203
	ErrorInternal      = 204
)
View Source
const (
	St_Normal uint8 = iota
	St_Warning
	St_Error
)

Variables

This section is empty.

Functions

func AllowSpecificRoute

func AllowSpecificRoute(allowedPath string) gin.HandlerFunc

func AttestationIdle

func AttestationIdle(cli *chain.ChainClient, peernode *core.PeerNode, p *Pois, r *RunningState, m *pb.MinerPoisInfo, teeRecord *TeeRecord, l *logger.Lg, cfg *confile.Confile, ch chan<- bool)

func CalcTag

func CalcTag(cli *chain.ChainClient, cace cache.Cache, l logger.Logger, r *RunningState, teeRecord *TeeRecord, cfg *confile.Confile, fileDir string, ch chan<- bool)

func ChallengeMgt

func ChallengeMgt(
	cli *chain.ChainClient,
	l logger.Logger,
	ws *Workspace,
	r *RunningState,
	teeRecord *TeeRecord,
	peernode *core.PeerNode,
	m *pb.MinerPoisInfo,
	rsa *RSAKeyPair,
	p *Pois,
	cfg *confile.Confile,
	cace cache.Cache,
	idleChallTaskCh chan bool,
	serviceChallTaskCh chan bool,
)

func GenIdle

func GenIdle(l *logger.Lg, prover *pois.Prover, r *RunningState, workspace string, useSpace uint64, ch chan<- bool)

func ProcessTeeEndpoint

func ProcessTeeEndpoint(endPoint string) string

func ReplaceIdle

func ReplaceIdle(cli *chain.ChainClient, l logger.Logger, p *Pois, m *pb.MinerPoisInfo, teeRecord *TeeRecord, peernode *core.PeerNode, ch chan<- bool)

func ReportFiles

func ReportFiles(ch chan<- bool, cli *chain.ChainClient, r *RunningState, l *logger.Lg, fileDir, tmpDir string)

func RestoreFiles

func RestoreFiles(cli *chain.ChainClient, cace cache.Cache, l logger.Logger, fileDir string, ch chan bool)

func RestoreLocalFiles

func RestoreLocalFiles(cli *chain.ChainClient, l logger.Logger, cace cache.Cache, fileDir string) error

func RestoreOtherFiles

func RestoreOtherFiles(cli *chain.ChainClient, l logger.Logger, fileDir string) error

func SplitByN

func SplitByN(filePath string, N int64) (Data [][]byte, sep int64, err error)

func Subscribe

func Subscribe(ctx context.Context, h host.Host, minerRecord MinerRecord, bootnode string)

func SyncTeeInfo

func SyncTeeInfo(cli *chain.ChainClient, l *logger.Lg, peernode *core.PeerNode, teeRecord *TeeRecord, ch chan<- bool)

func WatchMem

func WatchMem()

Types

type DataDir

type DataDir struct {
	DbDir           string
	LogDir          string
	SpaceDir        string
	PoisDir         string
	AccDir          string
	RandomDir       string
	PeersFile       string
	Podr2PubkeyFile string
}

type GenProofResponse

type GenProofResponse struct {
	Sigma     string    `json:"sigma"`
	MU        string    `json:"mu"`
	StatueMsg StatueMsg `json:"statue_msg"`
}

type GetStatus

type GetStatus interface {
	GetCpuCores() int
	GetPID() int
	GetLastReconnectRpcTime() string
	GetCalcTagFlag() bool
	GetReportFileFlag() bool
	GetGenIdleFlag() bool
	GetAuthIdleFlag() bool
	GetIdleChallengeFlag() bool
	GetServiceChallengeFlag() bool
	GetChainStatus() bool
	GetReceiveFlag() bool
	GetCurrentRpc() string

	// miner
	GetMinerState() string
	GetMinerSpaceInfo() (uint64, uint64, uint64, uint64)
	GetMinerSignatureAcc() string
}

type HashSelf

type HashSelf interface {
	New() *HashSelf
	LoadField(d []byte) error
	CHash() ([]byte, crypto.Hash)
}

type MinerRecord

type MinerRecord interface {
	// SavePeer saves or updates peer information
	SavePeer(addr peer.AddrInfo) error
	//
	HasPeer(peerid string) bool
	//
	GetPeer(peerid string) (peer.AddrInfo, error)
	//
	GetAllPeerId() []string
	//
	BackupPeer(path string) error
	//
	LoadPeer(path string) error
	//
	SaveMinerAcc(acc string, peerid string)
	//
	GetAllMinerAcc() []string
}

func NewPeerRecord

func NewPeerRecord() MinerRecord

type Node

type Node struct {
}

func New

func New() *Node

New is used to build a node instance

type PeerRecordType

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

func (*PeerRecordType) BackupPeer

func (p *PeerRecordType) BackupPeer(path string) error

func (*PeerRecordType) GetAllMinerAcc

func (p *PeerRecordType) GetAllMinerAcc() []string

func (*PeerRecordType) GetAllPeerId

func (p *PeerRecordType) GetAllPeerId() []string

func (*PeerRecordType) GetPeer

func (p *PeerRecordType) GetPeer(peerid string) (peer.AddrInfo, error)

func (*PeerRecordType) HasPeer

func (p *PeerRecordType) HasPeer(peerid string) bool

func (*PeerRecordType) LoadPeer

func (p *PeerRecordType) LoadPeer(path string) error

func (*PeerRecordType) SaveMinerAcc

func (p *PeerRecordType) SaveMinerAcc(acc string, peerid string)

func (*PeerRecordType) SavePeer

func (p *PeerRecordType) SavePeer(addr peer.AddrInfo) error

type Pois

type Pois struct {
	*pois.Prover
	*acc.RsaKey
}

func NewPOIS

func NewPOIS(poisDir, spaceDir, accDir string, expendersInfo chain.ExpendersInfo, register bool, front, rear, freeSpace, count int64, cpus int, key_n, key_g, signAccPulickey []byte) (*Pois, error)

type QElement

type QElement struct {
	I int64  `json:"i"`
	V string `json:"v"`
}

type RSAKeyPair

type RSAKeyPair struct {
	Spk *rsa.PublicKey
}

func NewRsaKey

func NewRsaKey(pubkey []byte) (*RSAKeyPair, error)

func (RSAKeyPair) AggrAppendProof

func (keyPair RSAKeyPair) AggrAppendProof(AggrSigma string, aSigma string) (string, bool)

func (RSAKeyPair) AggrGenProof

func (keyPair RSAKeyPair) AggrGenProof(QSlice []QElement, Tag []Tag) string

func (RSAKeyPair) GenProof

func (keyPair RSAKeyPair) GenProof(QSlice []QElement, h HashSelf, Phi []string, Matrix [][]byte) <-chan GenProofResponse

func (*RSAKeyPair) VerifyAttest

func (r *RSAKeyPair) VerifyAttest(name, u, phiHash, attest, customData string) (bool, error)

type RandomList

type RandomList struct {
	Index  []uint32 `json:"index"`
	Random [][]byte `json:"random"`
}

type RunningState

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

func NewRunTime

func NewRunTime() *RunningState

func (*RunningState) GetAuthIdleFlag

func (s *RunningState) GetAuthIdleFlag() bool

func (*RunningState) GetCalcTagFlag

func (s *RunningState) GetCalcTagFlag() bool

func (*RunningState) GetChainStatus

func (s *RunningState) GetChainStatus() bool

func (*RunningState) GetCpuCores

func (s *RunningState) GetCpuCores() int

func (*RunningState) GetCurrentRpc

func (s *RunningState) GetCurrentRpc() string

func (*RunningState) GetGenIdleFlag

func (s *RunningState) GetGenIdleFlag() bool

func (*RunningState) GetIdleChallengeFlag

func (s *RunningState) GetIdleChallengeFlag() bool

func (*RunningState) GetLastReconnectRpcTime

func (s *RunningState) GetLastReconnectRpcTime() string

func (*RunningState) GetMinerSignatureAcc

func (s *RunningState) GetMinerSignatureAcc() string

func (*RunningState) GetMinerSpaceInfo

func (m *RunningState) GetMinerSpaceInfo() (uint64, uint64, uint64, uint64)

func (*RunningState) GetMinerState

func (s *RunningState) GetMinerState() string

func (*RunningState) GetPID

func (s *RunningState) GetPID() int

func (*RunningState) GetReceiveFlag

func (s *RunningState) GetReceiveFlag() bool

func (*RunningState) GetReportFileFlag

func (s *RunningState) GetReportFileFlag() bool

func (*RunningState) GetServiceChallengeFlag

func (s *RunningState) GetServiceChallengeFlag() bool

func (*RunningState) ListenLocal

func (s *RunningState) ListenLocal()

func (*RunningState) SetAuthIdleFlag

func (s *RunningState) SetAuthIdleFlag(flag bool)

func (*RunningState) SetCalcTagFlag

func (s *RunningState) SetCalcTagFlag(flag bool)

func (*RunningState) SetChainStatus

func (s *RunningState) SetChainStatus(status bool)

func (*RunningState) SetCpuCores

func (s *RunningState) SetCpuCores(num int)

func (*RunningState) SetCurrentRpc

func (s *RunningState) SetCurrentRpc(rpc string)

func (*RunningState) SetGenIdleFlag

func (s *RunningState) SetGenIdleFlag(flag bool)

func (*RunningState) SetIdleChallengeFlag

func (s *RunningState) SetIdleChallengeFlag(flag bool)

func (*RunningState) SetLastReconnectRpcTime

func (s *RunningState) SetLastReconnectRpcTime(t string)

func (*RunningState) SetMinerSignAcc

func (m *RunningState) SetMinerSignAcc(acc string)

func (*RunningState) SetMinerSpaceInfo

func (m *RunningState) SetMinerSpaceInfo(decSpace, validSpace, usedSpace, lockedSpace uint64)

func (*RunningState) SetMinerState

func (m *RunningState) SetMinerState(state string) error

func (*RunningState) SetPID

func (s *RunningState) SetPID(pid int)

func (*RunningState) SetReceiveFlag

func (s *RunningState) SetReceiveFlag(flag bool)

func (*RunningState) SetReportFileFlag

func (s *RunningState) SetReportFileFlag(flag bool)

func (*RunningState) SetServiceChallengeFlag

func (s *RunningState) SetServiceChallengeFlag(flag bool)

type RunningStater

type RunningStater interface {
	SetStatus
	GetStatus
}

type SetStatus

type SetStatus interface {
	SetCpuCores(num int)
	SetPID(pid int)
	SetLastReconnectRpcTime(t string)
	SetCalcTagFlag(flag bool)
	SetReportFileFlag(flag bool)
	SetGenIdleFlag(flag bool)
	SetAuthIdleFlag(flag bool)
	SetIdleChallengeFlag(flag bool)
	SetServiceChallengeFlag(flag bool)
	SetChainStatus(status bool)
	SetReceiveFlag(flag bool)
	SetCurrentRpc(rpc string)

	// miner
	SetMinerState(state string) error
	SetMinerSpaceInfo(decSpace, validSpace, usedSpace, lockedSpace uint64)
	SetMinerSignAcc(acc string)
}

type StatueMsg

type StatueMsg struct {
	StatusCode int    `json:"status"`
	Msg        string `json:"msg"`
}

type T

type T struct {
	Name string   `json:"name"`
	U    string   `json:"u"`
	Phi  []string `json:"phi"`
}

type Tag

type Tag struct {
	T       T      `json:"t"`
	PhiHash string `json:"phi_hash"`
	Attest  string `json:"attest"`
}

type TagfileType

type TagfileType struct {
	Tag          *pb.Tag `protobuf:"bytes,1,opt,name=tag,proto3" json:"tag,omitempty"`
	USig         []byte  `protobuf:"bytes,2,opt,name=u_sig,json=uSig,proto3" json:"u_sig,omitempty"`
	Signature    []byte  `protobuf:"bytes,3,opt,name=signature,proto3" json:"signature,omitempty"`
	FragmentName []byte  `protobuf:"bytes,4,opt,name=fragment_name,json=fragmentName,proto3" json:"fragment_name,omitempty"`
	TeeAccountId []byte  `protobuf:"bytes,5,opt,name=tee_account_id,json=teeAccountId,proto3" json:"tee_account_id,omitempty"`
	Index        uint16  `protobuf:"bytes,6,opt,name=index,json=index,proto3" json:"index,omitempty"`
}

type TeeInfo

type TeeInfo struct {
	EndPoint string
	Type     uint8
}

type TeeRecord

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

func NewTeeRecord

func NewTeeRecord() *TeeRecord

func (*TeeRecord) DeleteTee

func (t *TeeRecord) DeleteTee(workAccount string)

func (*TeeRecord) GetAllMarkerTeeEndpoint

func (t *TeeRecord) GetAllMarkerTeeEndpoint() []string

func (*TeeRecord) GetAllTeeEndpoint

func (t *TeeRecord) GetAllTeeEndpoint() []string

func (*TeeRecord) GetAllVerifierTeeEndpoint

func (t *TeeRecord) GetAllVerifierTeeEndpoint() []string

func (*TeeRecord) GetTee

func (t *TeeRecord) GetTee(workAccount string) (TeeInfo, error)

func (*TeeRecord) GetTeeWorkAccount

func (t *TeeRecord) GetTeeWorkAccount(endpoint string) (string, error)

func (*TeeRecord) SaveTee

func (t *TeeRecord) SaveTee(workAccount, endPoint string, teeType uint8) error

SaveTee saves or updates tee information

type TeeRecorder

type TeeRecorder interface {
	// SaveTee saves or updates tee information
	SaveTee(workAccount, endPoint string, teeType uint8) error
	//
	GetTee(workAccount string) (TeeInfo, error)
	//
	GetTeeWorkAccount(endpoint string) (string, error)
	//
	DeleteTee(workAccount string)
	//
	GetAllTeeEndpoint() []string
	//
	GetAllMarkerTeeEndpoint() []string
	//
	GetAllVerifierTeeEndpoint() []string
}

type Workspace

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

func NewWorkspace

func NewWorkspace() *Workspace

func (*Workspace) Build

func (w *Workspace) Build(rootDir string) error

func (*Workspace) Check

func (w *Workspace) Check() error

func (*Workspace) GetChallRandomDir

func (w *Workspace) GetChallRandomDir() string

func (*Workspace) GetChallRndomDir

func (w *Workspace) GetChallRndomDir() string

func (*Workspace) GetDbDir

func (w *Workspace) GetDbDir() string

func (*Workspace) GetFileDir

func (w *Workspace) GetFileDir() string

func (*Workspace) GetIdleProve

func (w *Workspace) GetIdleProve() string

func (*Workspace) GetLogDir

func (w *Workspace) GetLogDir() string

func (*Workspace) GetPeerRecord

func (w *Workspace) GetPeerRecord() string

func (*Workspace) GetPodr2Key

func (w *Workspace) GetPodr2Key() string

func (*Workspace) GetPoisAccDir

func (w *Workspace) GetPoisAccDir() string

func (*Workspace) GetPoisDir

func (w *Workspace) GetPoisDir() string

func (*Workspace) GetRootDir

func (w *Workspace) GetRootDir() string

func (*Workspace) GetServiceProve

func (w *Workspace) GetServiceProve() string

func (*Workspace) GetSpaceDir

func (w *Workspace) GetSpaceDir() string

func (*Workspace) GetTmpDir

func (w *Workspace) GetTmpDir() string

func (*Workspace) LoadIdleProve

func (w *Workspace) LoadIdleProve() (idleProofInfo, error)

func (*Workspace) LoadRsaPublicKey

func (w *Workspace) LoadRsaPublicKey() ([]byte, error)

func (*Workspace) LoadServiceProve

func (w *Workspace) LoadServiceProve() (serviceProofInfo, error)

func (*Workspace) RemoveAndBuild

func (w *Workspace) RemoveAndBuild(rootDir string) error

func (*Workspace) SaveChallRandom

func (w *Workspace) SaveChallRandom(
	challStart uint32,
	randomIndexList []types.U32,
	randomList []chain.Random,
) error

func (*Workspace) SaveIdleProve

func (w *Workspace) SaveIdleProve(idleProofRecord idleProofInfo) error

func (*Workspace) SaveRsaPublicKey

func (w *Workspace) SaveRsaPublicKey(pub []byte) error

func (*Workspace) SaveServiceProve

func (w *Workspace) SaveServiceProve(serviceProofRecord serviceProofInfo) error

type Workspacer

type Workspacer interface {
	Build(rootDir string) error
	RemoveAndBuild(rootDir string) error
	GetRootDir() string
	GetFileDir() string
	GetTmpDir() string
	GetDbDir() string
	GetLogDir() string
	GetSpaceDir() string
	GetPoisDir() string
	GetPoisAccDir() string
	GetChallRndomDir() string
	GetPeerRecord() string
	GetPodr2Key() string
	GetIdleProve() string
	GetServiceProve() string
	SaveRsaPublicKey(pub []byte) error
	LoadRsaPublicKey() ([]byte, error)
	SaveIdleProve(idleProofRecord idleProofInfo) error
	LoadIdleProve() (idleProofInfo, error)
	SaveServiceProve(serviceProofRecord serviceProofInfo) error
	LoadServiceProve() (serviceProofInfo, error)
	SaveChallRandom(
		challStart uint32,
		randomIndexList []types.U32,
		randomList []chain.Random,
	) error
}

Jump to

Keyboard shortcuts

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