mirror of
https://github.com/luxfi/coreth.git
synced 2026-10-30 17:00:51 +00:00
Wave 2C of codec rip (#101). Two leaf migrations in coreth that do not depend on the atomic/ rip (Wave 2B): network/network_test.go: Replace the linearcodec+codec.NewManager test scaffold with a test-local testCodec implementing message.Manager (the only surface network.NewNetwork actually consumes from its codec parameter). Hand-rolled wire: u16 version, optional u32 typeID for pointer-to-interface marshalling, u16-length-prefixed strings for the small closed set of test types (Hello/Greeting Request/Response, TestMessage, HelloGossip). Production network.go already wired to message.Manager — this just removes the last codec.Manager smell from the test surface. tests/warp/aggregator/signature_getter.go: Drop the unused networkCodec field and constructor parameter. The field was stored but never read — request/response framing goes through warp.MarshalSignatureRequest / warp.UnmarshalSignatureResponse and never touched the codec. NewSignatureGetter has no callers in the tree (the only consumer in tests/warp/warp_test.go uses apiSignatureGetter), so dropping the parameter has no callsite fallout. Tests pass: network/ and tests/warp/aggregator/.
Peer Package
The peer package handles networking for the VM.
Network
The Network interface implements the networking portion of the required VM interface. The VM utilizes the Network interface to:
- Set an App Gossip handler for incoming VM gossip messages
- Set an App Request handler for incoming VM request messages
- Send App Requests to peers in the network and specify a response handler to be called upon receiving a response or failure notification
- Send App Gossip messages to the network
Client
The client utilizes the Network interface to send requests to peers on the network and utilizes the waitingHandler to wait until a response or failure is received from the Luxd networking layer.
This allows the user of Client to treat it as if it were returning results from the network synchronously.
result, err := client.Request(nodeID, request) // Blocks until receiving a response from the network
if err != nil {
return err
}
foo(result) // do something with the result