network

package
v0.0.0-...-a5060f3 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Open

func Open(addr string) (*bufio.ReadWriter, error)

func RewardsDistribution

func RewardsDistribution(bcnet *BlockchainNetwork)

Types

type BlockchainNetwork

type BlockchainNetwork struct {
	Transactions   []chain.LocalTransaction //pending transactions
	CandidateBlock chan chain.Block         //pending block
	BlockSender    map[string]int           //the sender of the candidate block
	VerifiedBlock  chain.Block              //the verfied block
	Members        chain.MemberSet          //committee members
	Nodes          chain.PeerSet            //the registered nodes in the network
	Task           TaskInfo                 //the task published in the network
	StakeMap       map[int]int              //the stake map of nodes
	Vrf            consensus.VRF            //stake based random role selection

	VoteLock      sync.Mutex //control the voting process
	CommitteeLock sync.Mutex //control the committee process
	BlockLock     sync.Mutex //control the candidate block receiving process
	TxLock        sync.Mutex //control the tx receiving process

	CommitteeWait  chan bool
	CommitteeSetup chan bool
	CandidateWait  chan bool
	BlockReceived  chan bool
	NewBlock       chan bool
	NewRound       chan bool
	NewTask        bool
}

func NetworkInit

func NetworkInit() *BlockchainNetwork

func (*BlockchainNetwork) CommitteeUpdate

func (bcnet *BlockchainNetwork) CommitteeUpdate(id int, members *[]chain.Member) error

func (*BlockchainNetwork) GetBlock

func (bcnet *BlockchainNetwork) GetBlock(id int, block *chain.Block) error

func (*BlockchainNetwork) GetTxs

func (bcnet *BlockchainNetwork) GetTxs(id int, txs *[]chain.LocalTransaction) error

func (*BlockchainNetwork) Register

func (bcnet *BlockchainNetwork) Register(nodeInfo RegisterInfo, reply *bool) error

func (*BlockchainNetwork) SendBlock

func (bcnet *BlockchainNetwork) SendBlock(candi Candidate, sent *bool) error

func (*BlockchainNetwork) SendRole

func (bcnet *BlockchainNetwork) SendRole(member chain.Member, committeeSetup *bool) error

func (*BlockchainNetwork) SendTx

func (bcnet *BlockchainNetwork) SendTx(tx chain.LocalTransaction, sent *bool) error

type Candidate

type Candidate struct {
	PendingBlock chain.Block
	Sender       int //the id number of the sender
}

type Endpoint

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

Endpoint provides an endpoint to other processess that they can send data to.

func NewEndpoint

func NewEndpoint() *Endpoint

NewEndpoint creates a new endpoint. To keep things simple, the endpoint listens on a fixed port number.

func (*Endpoint) AddHandleFunc

func (e *Endpoint) AddHandleFunc(name string, f HandleFunc)

AddHandleFunc adds a new function for handling incoming data.

func (*Endpoint) Listen

func (e *Endpoint) Listen(Port string) error

Listen starts listening on the endpoint port on all interfaces. At least one handler function must have been added through AddHandleFunc() before.

type HandleFunc

type HandleFunc func(*bufio.ReadWriter, net.Addr)

type RegisterInfo

type RegisterInfo struct {
	ID      int
	Address string
	Pk      vrf.PublicKey
}

type TaskInfo

type TaskInfo struct {
	TaskName      string
	Model         *python3.PyObject
	GlobalModel   string
	ModelSize     [][]int
	CompModelSize []int //the compressed model size
	PartNum       int   //the number of participants required in each training round
	Rank          int
	CurrentRound  int
	Beta          float64
	Slr           float64
	UnlabeledData *python3.PyObject
}

FL Task

Jump to

Keyboard shortcuts

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