Skip to content

Commit

Permalink
nits: integration changes (#308)
Browse files Browse the repository at this point in the history
Signed-off-by: Sander Pick <[email protected]>
  • Loading branch information
sanderpick authored Apr 13, 2020
1 parent e1b3ffe commit 33170c5
Show file tree
Hide file tree
Showing 7 changed files with 260 additions and 255 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.14.1-buster
FROM golang:1.14.2-buster
MAINTAINER Textile <[email protected]>

# This is (in large part) copied (with love) from
Expand Down
290 changes: 145 additions & 145 deletions api/pb/api.pb.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion api/pb/api.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
syntax = "proto3";
package api.pb;
package threads.pb;

option java_multiple_files = true;
option java_package = "io.textile.threads_grpc";
Expand Down
File renamed without changes.
207 changes: 104 additions & 103 deletions net/api/pb/api.pb.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion net/api/pb/api.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
syntax = "proto3";
package net.api.pb;
package threads.net.pb;

option java_multiple_files = true;
option java_package = "io.textile.threads_net_grpc";
Expand Down
12 changes: 8 additions & 4 deletions net/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -585,15 +585,16 @@ func (n *net) CreateRecord(ctx context.Context, id thread.ID, body format.Node,
for _, opt := range opts {
opt(args)
}
if _, err = thread.ValidateToken(n.getPrivKey(), args.Token); err != nil {
pk, err := thread.ValidateToken(n.getPrivKey(), args.Token)
if err != nil {
return
}

lg, err := n.getOrCreateOwnLog(id)
if err != nil {
return
}
rec, err := n.newRecord(ctx, id, lg, body)
rec, err := n.newRecord(ctx, id, lg, body, pk)
if err != nil {
return
}
Expand Down Expand Up @@ -829,7 +830,7 @@ func (n *net) putRecord(ctx context.Context, id thread.ID, lid peer.ID, rec core
}

// newRecord creates a new record with the given body as a new event body.
func (n *net) newRecord(ctx context.Context, id thread.ID, lg thread.LogInfo, body format.Node) (core.Record, error) {
func (n *net) newRecord(ctx context.Context, id thread.ID, lg thread.LogInfo, body format.Node, pk thread.PubKey) (core.Record, error) {
if lg.PrivKey == nil {
return nil, fmt.Errorf("a private-key is required to create records")
}
Expand All @@ -852,11 +853,14 @@ func (n *net) newRecord(ctx context.Context, id thread.ID, lg thread.LogInfo, bo
return nil, err
}

if pk == nil {
pk = thread.NewLibp2pPubKey(n.getPrivKey().GetPublic())
}
return cbor.CreateRecord(ctx, n, cbor.CreateRecordConfig{
Block: event,
Prev: lg.Head,
Key: lg.PrivKey,
PubKey: thread.NewLibp2pPubKey(n.getPrivKey().GetPublic()),
PubKey: pk,
ServiceKey: sk,
})
}
Expand Down

0 comments on commit 33170c5

Please sign in to comment.