DAG

package
v0.0.0-...-41c7706 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	TcpMethodJoin         = iota
	MethodReceiveGradient // Deal Local Training Result Reached.
	TcpMethodReceiveModel // Deal Blockchain Training Result Broadcast.
	TcpMethodCheckModel   // Check Model Training Result.
	TcpMethodReleaseGradient
	TcpMethodReleaseModel
	TcpMethodGetModel
	TcpMethodGetModelScore
	TcpMethodExchangeGH
)
View Source
const (
	UdpMethodRefresh = iota // Request Neighbor PeerInfo.
	UdpMethodReceive        // Receive Neighbor PeerInfo from other Peers.
	UdpMethodExit           // Remove Neighbor Exited.
)
View Source
const DefaultFirstJoinListenWaitingTime = 3 * time.Second
View Source
const DefaultIP = "127.0.0.1"

DefaultIP Using 127.0.0.1 for local test network.

View Source
const DefaultK = 2
View Source
const DefaultNeighborRefreshTimeGap = 5 * time.Second // time.Minute
View Source
const DefaultPackageTcpHeaderSize = 256
View Source
const DefaultPort = 8000
View Source
const DefaultRefreshTime = 5 * time.Second
View Source
const DefaultTcpLength = 8 // int64
View Source
const DefaultTcpPort = 9000

Variables

This section is empty.

Functions

func EncodeTcpMessage

func EncodeTcpMessage(data []byte) []byte

func ExecuteCommandString

func ExecuteCommandString(str string) *command.Result

func ExecuteCommandWithArgs

func ExecuteCommandWithArgs(command *command.Command) *command.Result

func OriginListenUdp4

func OriginListenUdp4(peer *Peer)

func SenderTcpFunc

func SenderTcpFunc(conn *net.Conn, method uint, data []byte)

func StartOrigin

func StartOrigin()

func TransferDataToPackage

func TransferDataToPackage(data []byte, typeCode uint) ([]byte, error)

func UnpackPeerInfoList

func UnpackPeerInfoList(data []byte) map[string]*PeerInfo

Types

type Block

type Block struct {
	Header    *Header  `json:"header" yaml:"header"`
	Body      *Body    `json:"block" yaml:"block"`
	Reference []*Block `json:"reference" yaml:"reference"`
}

Block DAG Data Structure.

func (*Block) AppendData

func (that *Block) AppendData(data []byte)

func (*Block) CalculateHeader

func (that *Block) CalculateHeader()

CalculateHeader After Block AppendData Finished.

func (*Block) Packaged

func (that *Block) Packaged()

Packaged Calculate Header.

func (*Block) Verify

func (that *Block) Verify() bool

Verify Verify Block Correction.

type Blockchain

type Blockchain struct {
	Bases []*Block `json:"bases" yaml:"bases"`
}

func (*Blockchain) Verify

func (that *Blockchain) Verify() bool

type Body

type Body struct {
	// H.E. Verify Information.
	Units []*pedersonCommitment.VerifiableMessageUint
	// Compression Gradients.
	Data [][]byte
}

func (*Body) GenerateHeader

func (that *Body) GenerateHeader(dealer *pedersonCommitment.DealerUnit) *Header

GenerateHeader Before Data Transfer, Exchange Arguments G and H.

func (*Body) Hash

func (that *Body) Hash() []byte

func (*Body) HashString

func (that *Body) HashString() string
type Header struct {
	// Blockchain Hash.
	Merkle []byte `json:"merkle" yaml:"merkle"`
	SHA512 []byte `json:"sha512" yaml:"sha512"`
	// Dealer Shows H.E. Arguments GH and Sum of Random and Commitment.
	Dealer *pedersonCommitment.DealerUnit `json:"dealer" yaml:"dealer"`
}

type Package

type Package struct {
	Type    uint   `json:"type" yaml:"type"`
	Message []byte `json:"message" yaml:"message"`
}

func UnpackPackage

func UnpackPackage(data []byte) *Package

type PackageTcpHeader

type PackageTcpHeader struct {
	Type   uint `json:"type" yaml:"type"`
	Length uint `json:"length" yaml:"length"`
}

func UnpackPackageTcpHeader

func UnpackPackageTcpHeader(data []byte) *PackageTcpHeader

type Peer

type Peer struct {
	Info   *PeerInfo   `json:"info" yaml:"info"`
	Router *PeerRouter `json:"router" yaml:"router"`
	Tasks  []*Task     `json:"tasks" yaml:"tasks"`
	// contains filtered or unexported fields
}

func GeneratePeer

func GeneratePeer(port, tcpPort uint) (*Peer, error)

func (*Peer) Exit

func (that *Peer) Exit()

func (*Peer) Join

func (that *Peer) Join()

func (*Peer) ReleaseModel

func (that *Peer) ReleaseModel() *Peer

func (*Peer) TcpBroadcast

func (that *Peer) TcpBroadcast(method uint, data []byte)

func (*Peer) Try

func (that *Peer) Try()

Try Train with Test Data and Get Result.

func (*Peer) UdpBroadcast

func (that *Peer) UdpBroadcast(data []byte)

type PeerInfo

type PeerInfo struct {
	Address string `json:"address" yaml:"address"`
	Port    uint   `json:"port" yaml:"port"`
	TcpPort uint   `json:"tcpPort" yaml:"tcpPort"`
}

func GetDefaultPeerInfo

func GetDefaultPeerInfo() *PeerInfo

func UnpackPeerInfo

func UnpackPeerInfo(data []byte) *PeerInfo

func (*PeerInfo) HashString

func (that *PeerInfo) HashString() string

func (*PeerInfo) TcpCommunicateWithPeer

func (that *PeerInfo) TcpCommunicateWithPeer(method uint, data []byte)

func (*PeerInfo) TcpListen

func (that *PeerInfo) TcpListen(f func(conn *net.Conn))

func (*PeerInfo) UdpListen

func (that *PeerInfo) UdpListen(f func([]byte), ctx context.Context)

func (*PeerInfo) UdpSendToPeer

func (that *PeerInfo) UdpSendToPeer(data []byte) error

type PeerRouter

type PeerRouter struct {
	//Neighbor []*PeerInfo `json:"neighbor" yaml:"neighbor"`
	Neighbor map[string]*PeerInfo `json:"neighbor" yaml:"neighbor"`
}

type SingleBlock

type SingleBlock struct {
	Header *SingleHeader `json:"header" yaml:"header"`
	Body   *SingleBody   `json:"body" yaml:"body"`
	Next   *SingleBlock  `json:"next" yaml:"next"`
	Back   *SingleBlock  `json:"back" yaml:"back"`
}

func (*SingleBlock) Verify

func (that *SingleBlock) Verify(backward *SingleBlock) bool

type SingleBody

type SingleBody struct {
	Data  []byte `json:"data" yaml:"data"`
	Nonce []byte `json:"nonce" yaml:"nonce"`
}

func (*SingleBody) GenerateHeader

func (that *SingleBody) GenerateHeader(forwardHash []byte) *SingleHeader

type SingleChain

type SingleChain struct {
	Genesis *SingleBlock `json:"genesis" yaml:"genesis"`
	Latest  *SingleBlock `json:"latest" yaml:"latest"`
}

func (*SingleChain) Append

func (that *SingleChain) Append(head *SingleBlock)

func (*SingleChain) Verify

func (that *SingleChain) Verify() bool

func (*SingleChain) VerifyFrom

func (that *SingleChain) VerifyFrom(block *SingleBlock) bool

type SingleHeader

type SingleHeader struct {
	Merkle []byte `json:"merkle" yaml:"merkle"`
	SHA512 []byte `json:"sha512" yaml:"sha512"`
}

type Task

type Task struct {
	Command   string      `json:"command" yaml:"command"`
	Timestamp time.Time   `json:"timestamp" yaml:"timestamp"`
	Reached   []*PeerInfo `json:"reached" yaml:"reached"`
}

func GenerateTask

func GenerateTask(command string, broadcast bool) *Task

func (*Task) Execute

func (that *Task) Execute() *command.Result

Jump to

Keyboard shortcuts

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