Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP/ PoC] Nimbus test #79

Merged
merged 1 commit into from Aug 1, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -13,6 +13,13 @@ build:
GOFLAGS=$(GOFLAGS) go build $(BUILD_FLAGS) -o ./bin/status-term-client .
.PHONY: build

# XXX: Multiple ldflags a bit brittle, keeping it simple by having separate build target for now.
# See https://github.com/golang/go/issues/29053
build-nimbus: GOFLAGS ?= "-mod=vendor"
build-nimbus:
GOFLAGS=$(GOFLAGS) go build -ldflags="-r /usr/local/lib" -tags nimbus -o ./bin/status-term-client .
.PHONY: build-nimbus

run: ARGS ?=
run: build
./bin/status-term-client $(ARGS) 2>/tmp/status-term-client.log
@@ -41,6 +41,52 @@ Currently the following commands are supported.

`/contact add <public-key> <name>`

# Packages

The main package contains the console user interface.

* `github.com/status-im/status-console-client/protocol/v1` contains the current messaging protocol payload encoders and decoders as well as some utilities like creating a Whisper topic for a public chat.

# (Very) Experimental Nimbus support

`status-console-client` supports very experimental Nimbus support for Whisper.

## How it works

1. Nimbus exposes a basic and very rough C API for Whisper polling, posting,
subscribing, and adding peers: https://github.com/status-im/nimbus/pull/331

2. This C API is consumed as a standard shared library, `libnimbus_api.so`.

3. [status-nim](https://github.com/status-im/status-nim) wraps this library to
expose a Go API. Currently, this "API" is more like a hacky spike. The goal is
for this to library to hide the integration details with Nim and provide a clean
Go interface for consumers.

## Building and running

The changes are isolated and won't impact `status-console-client` unless the
appropriate build instruction, flag and patch is provided.

### libnimbus_api.so

If you have issues with `libnimbus_api.so` (likely) you might want to copy it
into `/usr/local/lib` manually.

```
make build-nimbus
./bin/status-term-client -keyhex=0x9af3cdb76d76da2b36d2dcc082cb54ea672639331ef03b91a62ad6ef804b4896 -nimbus
```

Expected output:

```
[nim-status] posting ["~#c4",["Message:1000","text/plain","~:public-group-user-message",156393648280100,1563936482801,["^ ","~:chat-id","status-test-c","~:text","Message:1000"]]]
```

And a message being posted in `#status-test-c`.


# License

[Mozilla Public License 2.0](https://github.com/status-im/status-go/blob/develop/LICENSE.md)
1 go.mod
@@ -38,6 +38,7 @@ require (
github.com/sirupsen/logrus v1.4.2 // indirect
github.com/status-im/status-go v0.29.0-beta.3
github.com/status-im/status-protocol-go v0.0.0-20190624072549-28b2244fed6fef94d43f9c87be8f0b6cf54d7d20
github.com/status-im/status-nim v0.0.0-20190724023117-a5693e6e4820
github.com/stretchr/objx v0.2.0 // indirect
go.opencensus.io v0.22.0 // indirect
go.uber.org/zap v1.10.0
2 go.sum
@@ -518,6 +518,8 @@ github.com/status-im/status-go v0.29.0-beta.3 h1:0MzV9p1r+CVxCBrg+OrGDQ8v/6p+k6C
github.com/status-im/status-go v0.29.0-beta.3/go.mod h1:8OHekmRoYTn9oZgMsBdhMEgeyfaQ4eI4ycOFHJCoX7M=
github.com/status-im/status-protocol-go v0.0.0-20190624072549-28b2244fed6fef94d43f9c87be8f0b6cf54d7d20 h1:MC6dXIfgnqEONfjIhBlMZ6H/nvqanWYeGxgG7YxZRz4=
github.com/status-im/status-protocol-go v0.0.0-20190624072549-28b2244fed6fef94d43f9c87be8f0b6cf54d7d20/go.mod h1:K1sZNTGahmrliIsVDTPrruKMZqbbqd8inbfbfh9Wmw4=
github.com/status-im/status-nim v0.0.0-20190724023117-a5693e6e4820 h1:vcKYLWz2hFyYfsE5j2il+c3tellhOrkaGREaF6OCof4=
github.com/status-im/status-nim v0.0.0-20190724023117-a5693e6e4820/go.mod h1:q3TkDSDrrHpM9QAH2jS0WOKrw0UzhZzCNO/zKd4fBrk=
github.com/status-im/whisper v1.4.14 h1:9VHqx4+PUYfhDnYYtDxHkg/3cfVvkHjPNciY4LO83yc=
github.com/status-im/whisper v1.4.14/go.mod h1:WS6z39YJQ8WJa9s+DmTuEM/s2nVF6Iz3B1SZYw5cYf0=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
@@ -63,13 +63,19 @@ var (

// flags for external node
providerURI = fs.String("provider", "", "an URI pointing at a provider")

useNimbus = fs.Bool("nimbus", false, "use Nimbus node")
)

func main() {
if err := ff.Parse(fs, os.Args[1:]); err != nil {
exitErr(errors.Wrap(err, "failed to parse flags"))
}

if *useNimbus {
startNimbus()
}

if *createKeyPair {
key, err := crypto.GenerateKey()
if err != nil {
@@ -0,0 +1,17 @@
// +build nimbus

package main

import (
statusnim "github.com/status-im/status-nim"
"runtime"
)

func init() {
runtime.LockOSThread()
}

func startNimbus() {
statusnim.Start()
statusnim.ListenAndPost()
}
@@ -0,0 +1,7 @@
// +build !nimbus

package main

func startNimbus() {
panic("executable needs to be built with -tags nimbus")
}

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

Binary file not shown.
Binary file not shown.
Binary file not shown.

Some generated files are not rendered by default. Learn more.

Some generated files are not rendered by default. Learn more.

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.