aboutsummaryrefslogtreecommitdiffstats
path: root/ethwire/README.md
blob: 7f63688b3cfe2e083c1eeeb4a3096975442c94c1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# ethwire

The ethwire package contains the ethereum wire protocol. The ethwire
package is required to write and read from the ethereum network.

# Installation

`go get github.com/ethereum/ethwire-go`

# Messaging overview

The Ethereum Wire protocol defines the communication between the nodes
running Ethereum. Further reader reading can be done on the
[Wiki](http://wiki.ethereum.org/index.php/Wire_Protocol).

# Reading Messages

```go
// Read and validate the next eth message from the provided connection.
// returns a error message with the details.
msg, err := ethwire.ReadMessage(conn)
if err != nil {
  // Handle error
}
```

# Writing Messages

```go
// Constructs a message which can be interpreted by the eth network.
// Write the inventory to network
err := ethwire.WriteMessage(conn, &Msg{
  Type: ethwire.MsgInvTy,
  Data : []interface{}{...},
})
```