Skip to content

Commit

Permalink
Merge pull request #36 from Bit-Nation/feature/protbuf_api_switch
Browse files Browse the repository at this point in the history
keystore api switch
  • Loading branch information
florianlenz authored Jun 19, 2018
2 parents 169ca35 + bd7e612 commit 942fab6
Show file tree
Hide file tree
Showing 27 changed files with 1,267 additions and 2,224 deletions.
10 changes: 2 additions & 8 deletions Gopkg.lock

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

4 changes: 0 additions & 4 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@
branch = "master"
name = "github.com/Bit-Nation/x3dh"

[[constraint]]
name = "github.com/asaskevich/govalidator"
version = "9.0.0"

[[constraint]]
name = "github.com/ethereum/go-ethereum"
version = "1.8.11"
Expand Down
8 changes: 6 additions & 2 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func New(client UpStream) *API {
}

type API struct {
DoubleRatchetKeyStoreApi
lock sync.Mutex
requests map[string]chan *Response
client UpStream
Expand All @@ -40,7 +41,7 @@ type API struct {
type Response struct {
Msg *pb.Response
Error error
Closer <-chan error
Closer chan error
}

// send a response for a received api request
Expand Down Expand Up @@ -125,7 +126,10 @@ func (a *API) request(req *pb.Request, timeOut time.Duration) (*Response, error)
// or time out
select {
case res := <-reqChan:
return res, nil
if res.Error != nil {
res.Closer <- nil
}
return res, res.Error
case <-time.After(timeOut):
// remove request from stack
_, err := a.cutRequest(requestId.String())
Expand Down
6 changes: 2 additions & 4 deletions api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,15 @@ func TestRequestResponse(t *testing.T) {
panic(err)
}
receivedRequestID = req.RequestID
out := api.Respond(req.RequestID, &pb.Response{
RequestID: req.RequestID,
}, nil, time.Second)
out := api.Respond(req.RequestID, &pb.Response{}, nil, time.Second)
if out != nil {
panic("expected nil but got: " + out.Error())
}
}
}()

resp, err := api.request(&pb.Request{}, time.Second)
resp.Closer <- nil
require.Nil(t, err)
require.Equal(t, resp.Msg.RequestID, receivedRequestID)

}
153 changes: 0 additions & 153 deletions api/device/api.go

This file was deleted.

118 changes: 0 additions & 118 deletions api/device/api_test.go

This file was deleted.

15 changes: 0 additions & 15 deletions api/device/rpc/contacts.go

This file was deleted.

12 changes: 0 additions & 12 deletions api/device/rpc/main.go

This file was deleted.

Loading

0 comments on commit 942fab6

Please sign in to comment.