hyperledger-iroha / iroha-dco

Iroha - A simple, decentralized ledger
http://iroha.tech
Apache License 2.0
988 stars 296 forks source link

Some suggestions for java interface #831

Closed mrZizik closed 6 years ago

mrZizik commented 6 years ago

1 - crypto.convertFromExisting(readKeyFromFile("../admin@test.pub"), readKeyFromFile("../admin@test.priv")); Why don't we overload that method to handle filepaths and read them too?

2 - Instead

private static ModelTransactionBuilder txBuilder = new ModelTransactionBuilder();
...
txBuilder.creatorAccountId(creator)
            .createdTime(BigInteger.valueOf(currentTime))
            .txCounter(BigInteger.valueOf(startTxCounter))
            .createDomain("ru", "user")
            .createAsset("dollar", "ru", (short)2).build();

this

ModelTransaction.builder()
            .creatorAccountId(creator)
            .createdTime(BigInteger.valueOf(currentTime))
            .txCounter(BigInteger.valueOf(startTxCounter))
            .createDomain("ru", "user")
            .createAsset("dollar", "ru", (short)2).build();

Same for other builder.

3 - Make this method static and don't create unnecessary objects.

protoTxHelper.signAndAddSignature(utx, keys).blob();

4 - I think clients don't need to know about GRPC and stuff.

Instead:

ManagedChannel channel = ManagedChannelBuilder.forAddress("localhost", 50051).usePlaintext(true).build();
        CommandServiceBlockingStub stub = CommandServiceGrpc.newBlockingStub(channel);
stub.torii(prototx)

this

client = Client.builder().forAddress("localhost",50051).usePlaintext(true)....build();
client.torii(protox);
neewy commented 6 years ago

what do you think guys? @luckychess @lebdron

l4l commented 6 years ago

As reality show the swig interface usually enough, and in fact maintaining additional binding code can be quite messy and inconsistent. Moreover some wrappers around generated bindings can be done by yourself