Skip to content

Commit

Permalink
java: adds missing delete db method (textileio#313)
Browse files Browse the repository at this point in the history
Signed-off-by: Sander Pick <[email protected]>
  • Loading branch information
sanderpick committed Apr 17, 2020
1 parent 4da1c9a commit e72593a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,18 @@ public void GetDBInfo (ByteString dbID, StreamObserver<GetDBInfoReply> responseO
asyncStub.getDBInfo(request.build(), responseObserver);
}

public DeleteDBReply DeleteDBSync (ByteString dbID) {
DeleteDBRequest.Builder request = DeleteDBRequest.newBuilder();
request.setDbID(dbID);
return blockingStub.deleteDB(request.build());
}

public void DeleteDB (ByteString dbID, StreamObserver<DeleteDBReply> responseObserver) {
DeleteDBRequest.Builder request = DeleteDBRequest.newBuilder();
request.setDbID(dbID);
asyncStub.deleteDB(request.build(), responseObserver);
}

public CreateReply CreateSync (ByteString dbID, String collectionName, ByteString[] instances) {
CreateRequest.Builder request = CreateRequest.newBuilder();
request.setDbID(dbID);
Expand Down
14 changes: 9 additions & 5 deletions core/thread/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package thread
import (
"context"
"encoding"
"encoding/base64"
"fmt"
"log"
"strings"
Expand All @@ -13,6 +12,7 @@ import (
"github.com/gogo/status"
"github.com/grpc-ecosystem/go-grpc-middleware/util/metautils"
"github.com/libp2p/go-libp2p-core/crypto"
mbase "github.com/multiformats/go-multibase"
jwted25519 "github.com/textileio/go-threads/jwt"
"google.golang.org/grpc/codes"
)
Expand Down Expand Up @@ -51,9 +51,9 @@ type PubKey interface {
encoding.BinaryMarshaler
encoding.BinaryUnmarshaler

// String encodes the public key into a base64 string.
// String encodes the public key into a base32 string.
fmt.Stringer
// UnmarshalString decodes a public key from a base64 string.
// UnmarshalString decodes a public key from a base32 string.
UnmarshalString(string) error
// Verify that 'sig' is the signed hash of 'data'
Verify(data []byte, sig []byte) (bool, error)
Expand Down Expand Up @@ -86,11 +86,15 @@ func (p *Libp2pPubKey) String() string {
if err != nil {
panic(err)
}
return base64.StdEncoding.EncodeToString(bytes)
str, err := mbase.Encode(mbase.Base32, bytes)
if err != nil {
panic(err)
}
return str
}

func (p *Libp2pPubKey) UnmarshalString(str string) error {
bytes, err := base64.StdEncoding.DecodeString(str)
_, bytes, err := mbase.Decode(str)
if err != nil {
return err
}
Expand Down

0 comments on commit e72593a

Please sign in to comment.