Skip to content

Commit

Permalink
Delete old fastboardcast function
Browse files Browse the repository at this point in the history
  • Loading branch information
kerwenwwer committed Apr 9, 2024
1 parent 010e3b8 commit ca318ab
Showing 1 changed file with 0 additions and 66 deletions.
66 changes: 0 additions & 66 deletions cmd/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,72 +188,6 @@ func broadcast(nodeList *NodeList, p common.Packet) {
}
}

// func fastBroadcast(nodeList *NodeList, p common.Packet) {
// nodes := nodeList.Get()
// var targetNodes []common.Node

// // Select some uninfected nodes
// i := 0

// for _, v := range nodes {

// // If the maximum number of pushes (Amount) has been reached
// if i >= nodeList.Amount {
// // Stop the broadcast
// break
// }

// if v.Addr == nodeList.localNode.Addr && v.Port == nodeList.localNode.Port {
// // Skip to broadcast to self
// continue
// }

// // If the node has already been "infected"
// if p.Infected[v.Addr+":"+strconv.Itoa(v.Port)] {
// // Skip this node
// continue
// }

// p.Infected[v.Addr+":"+strconv.Itoa(v.Port)] = true // Mark the node as infected
// // Set the target node for sending
// targetNode := common.Node{
// Addr: v.Addr, // Set the target address
// Port: v.Port, // Set the target port
// Mac: v.Mac, // Set the target mac
// }

// // Add the node to the broadcast list
// targetNodes = append(targetNodes, targetNode)
// i++
// }

// if len(targetNodes) != 0 {
// /* Handle atomic counter operation for map_id*/
// map_id := nodeList.Counter.Next()
// if map_id == 0 {
// nodeList.println("[Map ID error]: map_id is 0")
// }
// p.Mapkey = map_id
// p.Type = 1

// if err := bpf.TcPushtoMap(nodeList.Program, map_id, targetNodes); err != nil {
// nodeList.println("[TC error]:", "Failed to push to map", err)
// }

// bs, err := json.Marshal(p)
// if err != nil {
// nodeList.println("[Infection Error]:", err)
// }

// addr := targetNodes[0].Addr
// port := targetNodes[0].Port

// write(nodeList, addr, int(port), bs) // Send the packet
// } else {
// //nodeList.println("[Not target]:", "No target nodes")
// }
// }

func fastBroadcast(nodeList *NodeList, p common.Packet) {
nodes := nodeList.Get()
var targetNodes []common.Node
Expand Down

0 comments on commit ca318ab

Please sign in to comment.