pull/76/head
Minh Doan 6 years ago
parent e6e4e4a7dd
commit 7f9c81874d
  1. 2
      client/txgen/main.go
  2. 1
      identitychain/identitychain.go
  3. 2
      node/node_handler.go
  4. 6
      p2p/peer.go

@ -286,7 +286,7 @@ func main() {
// Nodes containing utxopools to mirror the shards' data in the network
nodes := []*node.Node{}
for shardID, _ := range shardIDLeaderMap {
for shardID := range shardIDLeaderMap {
node := node.New(&consensus.Consensus{ShardID: shardID}, nil)
// Assign many fake addresses so we have enough address to play with at first
node.AddTestingAddresses(setting.numOfAddress)

@ -61,7 +61,6 @@ func (IDC *IdentityChain) Shard() {
//ElectLeaders
func (IDC *IdentityChain) ElectLeaders() {
return
}
//BroadCastNewConfiguration

@ -30,7 +30,7 @@ const (
// MaybeBroadcastAsValidator returns if the node is a validator node.
func (node *Node) MaybeBroadcastAsValidator(content []byte) {
if node.SelfPeer.ValidatorID > 0 && node.SelfPeer.ValidatorID <= p2p.MAX_BROADCAST {
if node.SelfPeer.ValidatorID > 0 && node.SelfPeer.ValidatorID <= p2p.MaxBroadCast {
go p2p.BroadcastMessageFromValidator(node.SelfPeer, node.Consensus.GetValidatorPeers(), content)
}
}

@ -24,7 +24,7 @@ type Peer struct {
// TODO(minhdoan, rj): use this Ready to not send/broadcast to this peer if it wasn't available.
}
const MAX_BROADCAST = 20
const MaxBroadCast = 20
// SendMessage sends the message to the peer
func SendMessage(peer Peer, msg []byte) {
@ -64,14 +64,14 @@ func SelectMyPeers(peers []Peer, min int, max int) []Peer {
// BroadcastMessage sends the message to a list of peers from a leader.
func BroadcastMessageFromLeader(peers []Peer, msg []byte) {
// TODO(minhdoan): Enable back for multicast.
peers = SelectMyPeers(peers, 1, MAX_BROADCAST)
peers = SelectMyPeers(peers, 1, MaxBroadCast)
BroadcastMessage(peers, msg)
log.Info("Done sending from leader")
}
// BroadcastMessage sends the message to a list of peers from a validator.
func BroadcastMessageFromValidator(selfPeer Peer, peers []Peer, msg []byte) {
peers = SelectMyPeers(peers, selfPeer.ValidatorID*MAX_BROADCAST+1, (selfPeer.ValidatorID+1)*MAX_BROADCAST)
peers = SelectMyPeers(peers, selfPeer.ValidatorID*MaxBroadCast+1, (selfPeer.ValidatorID+1)*MaxBroadCast)
BroadcastMessage(peers, msg)
log.Info("Done sending from validator")
}

Loading…
Cancel
Save