mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-28 07:36:44 +00:00
subpackages: * adapters: * msgpipes for simulated test connections * rlpx the RLPx adapter for normal non-test use * inproc simulated in-process network adapter * docker placeholder for docker cluster remote adapter * protocols: easy-to-setup modular protocols * simulations: * generic network model * journal, events, snapshots * cytoscape visualisation plugin * resourceful controller suite + REST API server * example: connectivity UX backend * testing: test resource drivers * exchange: trigger/expect style driver for single node and its peers * sessions: for unit testing protocols and protocol modules * (network: for network testing, benchmarking, stats, correctness, fault tolerance) * test peerpool see more in the README-s in each subpackage * p2p/server : conn/disconn hooks * reporter remote client skeleton
53 lines
1.1 KiB
Go
53 lines
1.1 KiB
Go
package adapters
|
|
|
|
import (
|
|
"fmt"
|
|
"net"
|
|
// "net/http"
|
|
// "time"
|
|
)
|
|
|
|
func NewRemoteNode(id *NodeId, n Network, m Messenger) *RemoteNode {
|
|
return &RemoteNode{
|
|
ID: id,
|
|
Network: n,
|
|
}
|
|
}
|
|
|
|
// RemoteNode is the network adapter that
|
|
type RemoteNode struct {
|
|
ID *NodeId
|
|
addr net.Addr
|
|
Network
|
|
}
|
|
|
|
func Name(id []byte) string {
|
|
return fmt.Sprintf("test-%08x", id)
|
|
}
|
|
|
|
// inject(s) sends an RPC command remotely via ssh to the particular dockernode
|
|
func (self *RemoteNode) inject(string) error {
|
|
return nil
|
|
}
|
|
|
|
func (self *RemoteNode) LocalAddr() []byte {
|
|
return []byte(self.addr.String())
|
|
}
|
|
|
|
func (self *RemoteNode) ParseAddr(p []byte, s string) ([]byte, error) {
|
|
return p, nil
|
|
}
|
|
|
|
func (self *RemoteNode) Disconnect(rid []byte) error {
|
|
// ssh+ipc -> drop
|
|
// assumes the remote node is running the p2p module as part of the protocol
|
|
cmd := fmt.Sprintf(`p2p.Drop("%v")`, string(rid))
|
|
return self.inject(cmd)
|
|
}
|
|
|
|
func (self *RemoteNode) Connect(rid []byte) error {
|
|
// ssh+ipc -> connect
|
|
//
|
|
cmd := fmt.Sprintf(`admin.addPeer("%v")`, string(rid))
|
|
return self.inject(cmd)
|
|
}
|