|
|
@ -3,12 +3,14 @@ package p2p |
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"bytes" |
|
|
|
"bytes" |
|
|
|
"encoding/binary" |
|
|
|
"encoding/binary" |
|
|
|
"log" |
|
|
|
|
|
|
|
"net" |
|
|
|
"net" |
|
|
|
|
|
|
|
"runtime" |
|
|
|
"strings" |
|
|
|
"strings" |
|
|
|
"sync" |
|
|
|
"sync" |
|
|
|
|
|
|
|
"time" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/simple-rules/harmony-benchmark/attack" |
|
|
|
"github.com/simple-rules/harmony-benchmark/attack" |
|
|
|
|
|
|
|
"github.com/simple-rules/harmony-benchmark/log" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/dedis/kyber" |
|
|
|
"github.com/dedis/kyber" |
|
|
|
) |
|
|
|
) |
|
|
@ -38,6 +40,8 @@ func BroadcastMessage(peers []Peer, msg []byte) { |
|
|
|
var wg sync.WaitGroup |
|
|
|
var wg sync.WaitGroup |
|
|
|
wg.Add(len(peers)) |
|
|
|
wg.Add(len(peers)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.Info("Start Broadcasting", "gomaxprocs", runtime.GOMAXPROCS(0)) |
|
|
|
|
|
|
|
start := time.Now() |
|
|
|
for _, peer := range peers { |
|
|
|
for _, peer := range peers { |
|
|
|
peerCopy := peer |
|
|
|
peerCopy := peer |
|
|
|
go func() { |
|
|
|
go func() { |
|
|
@ -46,6 +50,7 @@ func BroadcastMessage(peers []Peer, msg []byte) { |
|
|
|
}() |
|
|
|
}() |
|
|
|
} |
|
|
|
} |
|
|
|
wg.Wait() |
|
|
|
wg.Wait() |
|
|
|
|
|
|
|
log.Info("Broadcasting Down", "time spent", time.Now().Sub(start).Seconds()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ConstructP2pMessage constructs the p2p message as [messageType, contentSize, content]
|
|
|
|
// ConstructP2pMessage constructs the p2p message as [messageType, contentSize, content]
|
|
|
|