Skip to content
This repository has been archived by the owner on Mar 5, 2020. It is now read-only.

Commit

Permalink
WORKS! Boot connects to the mesh.. bim bam !
Browse files Browse the repository at this point in the history
  • Loading branch information
abourget committed May 3, 2018
1 parent 1fd6d67 commit e1c78e5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
7 changes: 7 additions & 0 deletions bios.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ func (b *BIOS) RunBootSequence(secretP2PAddress string) error {
}
}

otherPeers := b.someTopmostPeersAddresses()
if err = b.DispatchBootConnectMesh(otherPeers); err != nil {
return fmt.Errorf("dispatch boot_connect_mesh: %s", err)
}

if err = b.DispatchBootPublishHandoff(); err != nil {
return fmt.Errorf("dispatch boot_publish_handoff: %s", err)
}
Expand Down Expand Up @@ -448,6 +453,8 @@ func (b *BIOS) waitOnHandoff(genesis *GenesisJSON) {
privKey = string(cnt)
}

privKey = strings.TrimSpace(privKey)

key, err := ecc.NewPrivateKey(privKey)
if err != nil {
fmt.Println("Invalid private key pasted:", err)
Expand Down
13 changes: 13 additions & 0 deletions mesh.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,16 @@ func (b *BIOS) computeMyMeshP2PAddresses() []string {
}
return otherPeers
}

func (b *BIOS) someTopmostPeersAddresses() []string {
// TODO: refine this algo..
// connect to some randomly, but more of the top-most
otherPeers := []string{}
for idx, peer := range b.ShuffledProducers {
if idx > 5 {
return otherPeers
}
otherPeers = append(otherPeers, peer.Discovery.EOSIOP2P)
}
return otherPeers
}
2 changes: 1 addition & 1 deletion sample_config/hook_boot_connect_mesh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

echo "Adding p2p-peer-address'es to config.ini"

echo $1 >> config.ini
echo "$1" >> config.ini


echo "Restarting boot node"
Expand Down
2 changes: 1 addition & 1 deletion sample_config/hook_join_network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ echo "$4" >> config.ini
echo "private-key = [\"$PUBKEY\",\"$PRIVKEY\"]" >> config.ini

echo "Running 'nodeos' through Docker."
docker run -ti --rm --detach --name nodeos-bios \
docker run -ti --detach --name nodeos-bios \
-v `pwd`:/etc/nodeos -v /tmp/nodeos-data:/data \
-p 8888:8888 -p 9876:9876 \
eosio/eos:dawn3x \
Expand Down

0 comments on commit e1c78e5

Please sign in to comment.