You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a simple way to integrate libp2p and to begin our experimentation of libp2p into our repo, we can start by setting up a bootnode that serves a simple echo server, and attach another libp2p node to our sharding node as a Service (see #127). Let's keep this constrained a package called p2p under the sharding package in our repo.
We can register this echo service in the registerShardingServices func in cmd/geth/shardingcmd.go
// registerShardingServices sets up either a notary or proposer// sharding service dependent on the ClientType cli flag. We should be defining// the services we want to register here, as this is the geth command entry point// for sharding.funcregisterShardingServices(n node.Node) error {
protocolFlag:=n.Context().GlobalString(utils.ProtocolFlag.Name)
err:=n.Register(func(ctx*cli.Context) (sharding.Service, error) {
// TODO(terenc3t): handle case when we just want to start an observer node.ifprotocolFlag=="notary" {
returnnotary.NewNotary(n.Context(), n)
}
returnproposer.NewProposer(n.Context(), n)
})
iferr!=nil {
returnfmt.Errorf("failed to register the main sharding services: %v", err)
}
// TODO: registers the shardp2p service.// we can do n.Register and initialize a shardp2p.NewServer() or something like that.returnnil
}
Then, in the submit collation function of the notary package, as the notary protocol will have access to the sharding node, we can call out an echo request using this shardp2p service and get an output.
What This Achieves
This would at least allow us to get our hands dirty with libp2p and see how we can write useful functions we can call throughout our notary or proposer protocols. This code will eventually evolve into registering another service in the sharding node for discovery, and more.
The text was updated successfully, but these errors were encountered:
Hi all,
As a simple way to integrate libp2p and to begin our experimentation of libp2p into our repo, we can start by setting up a bootnode that serves a simple echo server, and attach another libp2p node to our sharding node as a
Service
(see #127). Let's keep this constrained a package calledp2p
under thesharding
package in our repo.We can register this echo service in the
registerShardingServices
func incmd/geth/shardingcmd.go
Then, in the submit collation function of the
notary
package, as the notary protocol will have access to the sharding node, we can call out an echo request using this shardp2p service and get an output.What This Achieves
This would at least allow us to get our hands dirty with libp2p and see how we can write useful functions we can call throughout our notary or proposer protocols. This code will eventually evolve into registering another service in the sharding node for discovery, and more.
The text was updated successfully, but these errors were encountered: