Skip to content

Commit

Permalink
Merge branch 'master' into network/context-signing
Browse files Browse the repository at this point in the history
  • Loading branch information
jack0 committed Oct 16, 2018
2 parents 89ffd21 + e83afc3 commit 2e46957
Show file tree
Hide file tree
Showing 13 changed files with 355 additions and 75 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,13 @@ peer discovery within your application.
## Handling Messages

All messages that pass through **noise** are serialized/deserialized as
[protobufs](https://developers.google.com/protocol-buffers/).
[protobufs](https://developers.google.com/protocol-buffers/). If you want to
use a new message type for your application, you must first register your
message type.

```go
opcode.RegisterMessageType(opcode.Opcode(1000), &MyNewProtobufMessage{})
```

On a spawned `us-east1-b` Google Cloud (GCP) cluster comprised of 8
`n1-standard-1` (1 vCPU, 3.75GB memory) instances, **noise** is able to sign,
Expand Down
3 changes: 3 additions & 0 deletions examples/basic/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/perlin-network/noise/examples/basic/messages"
"github.com/perlin-network/noise/network"
"github.com/perlin-network/noise/network/discovery"
"github.com/perlin-network/noise/types/opcode"
)

// BasicPlugin buffers all messages into a mailbox for this test.
Expand Down Expand Up @@ -75,6 +76,8 @@ func ExampleBasicPlugin() {
}
}

opcode.RegisterMessageType(opcode.Opcode(1000), &messages.BasicMessage{})

// Wait for all nodes to finish discovering other peers.
time.Sleep(1 * time.Second)

Expand Down
4 changes: 4 additions & 0 deletions examples/proxy/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"github.com/perlin-network/noise/network"
"github.com/perlin-network/noise/network/discovery"
"github.com/perlin-network/noise/peer"
"github.com/perlin-network/noise/types/opcode"

"github.com/pkg/errors"
)

Expand Down Expand Up @@ -105,6 +107,8 @@ func ExampleProxyPlugin() {
var nodes []*network.Network
var plugins []*ProxyPlugin

opcode.RegisterMessageType(opcode.Opcode(1000), &messages.ProxyMessage{})

for i := 0; i < numNodes; i++ {
addr := fmt.Sprintf("tcp://%s:%d", host, startPort+i)
ids[addr] = i
Expand Down
6 changes: 6 additions & 0 deletions examples/request_benchmark/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/perlin-network/noise/log"
"github.com/perlin-network/noise/network"
"github.com/perlin-network/noise/network/discovery"
"github.com/perlin-network/noise/types/opcode"

"github.com/pkg/errors"
)
Expand All @@ -25,6 +26,11 @@ const (
startPort = 23000
)

func init() {
opcode.RegisterMessageType(opcode.Opcode(1000), &messages.LoadRequest{})
opcode.RegisterMessageType(opcode.Opcode(1001), &messages.LoadReply{})
}

func main() {
fmt.Print(run())
}
Expand Down
153 changes: 94 additions & 59 deletions internal/protobuf/stream.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2e46957

Please sign in to comment.