Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

feat: implement getConsensusParams method #126

Merged
merged 4 commits into from
Aug 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,18 @@ private PlatformGrpc() {}
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
org.dash.platform.dapi.v0.PlatformOuterClass.WaitForStateTransitionResultResponse.getDefaultInstance()))
.build();
@io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
public static final io.grpc.MethodDescriptor<org.dash.platform.dapi.v0.PlatformOuterClass.GetConsensusParamsRequest,
org.dash.platform.dapi.v0.PlatformOuterClass.GetConsensusParamsResponse> METHOD_GET_CONSENSUS_PARAMS =
io.grpc.MethodDescriptor.<org.dash.platform.dapi.v0.PlatformOuterClass.GetConsensusParamsRequest, org.dash.platform.dapi.v0.PlatformOuterClass.GetConsensusParamsResponse>newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.UNARY)
.setFullMethodName(generateFullMethodName(
"org.dash.platform.dapi.v0.Platform", "getConsensusParams"))
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
org.dash.platform.dapi.v0.PlatformOuterClass.GetConsensusParamsRequest.getDefaultInstance()))
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
org.dash.platform.dapi.v0.PlatformOuterClass.GetConsensusParamsResponse.getDefaultInstance()))
.build();

/**
* Creates a new async stub that supports all call types for the service
Expand Down Expand Up @@ -188,6 +200,13 @@ public void waitForStateTransitionResult(org.dash.platform.dapi.v0.PlatformOuter
asyncUnimplementedUnaryCall(METHOD_WAIT_FOR_STATE_TRANSITION_RESULT, responseObserver);
}

/**
*/
public void getConsensusParams(org.dash.platform.dapi.v0.PlatformOuterClass.GetConsensusParamsRequest request,
io.grpc.stub.StreamObserver<org.dash.platform.dapi.v0.PlatformOuterClass.GetConsensusParamsResponse> responseObserver) {
asyncUnimplementedUnaryCall(METHOD_GET_CONSENSUS_PARAMS, responseObserver);
}

@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
.addMethod(
Expand Down Expand Up @@ -239,6 +258,13 @@ public void waitForStateTransitionResult(org.dash.platform.dapi.v0.PlatformOuter
org.dash.platform.dapi.v0.PlatformOuterClass.WaitForStateTransitionResultRequest,
org.dash.platform.dapi.v0.PlatformOuterClass.WaitForStateTransitionResultResponse>(
this, METHODID_WAIT_FOR_STATE_TRANSITION_RESULT)))
.addMethod(
METHOD_GET_CONSENSUS_PARAMS,
asyncUnaryCall(
new MethodHandlers<
org.dash.platform.dapi.v0.PlatformOuterClass.GetConsensusParamsRequest,
org.dash.platform.dapi.v0.PlatformOuterClass.GetConsensusParamsResponse>(
this, METHODID_GET_CONSENSUS_PARAMS)))
.build();
}
}
Expand Down Expand Up @@ -316,6 +342,14 @@ public void waitForStateTransitionResult(org.dash.platform.dapi.v0.PlatformOuter
asyncUnaryCall(
getChannel().newCall(METHOD_WAIT_FOR_STATE_TRANSITION_RESULT, getCallOptions()), request, responseObserver);
}

/**
*/
public void getConsensusParams(org.dash.platform.dapi.v0.PlatformOuterClass.GetConsensusParamsRequest request,
io.grpc.stub.StreamObserver<org.dash.platform.dapi.v0.PlatformOuterClass.GetConsensusParamsResponse> responseObserver) {
asyncUnaryCall(
getChannel().newCall(METHOD_GET_CONSENSUS_PARAMS, getCallOptions()), request, responseObserver);
}
}

/**
Expand Down Expand Up @@ -384,6 +418,13 @@ public org.dash.platform.dapi.v0.PlatformOuterClass.WaitForStateTransitionResult
return blockingUnaryCall(
getChannel(), METHOD_WAIT_FOR_STATE_TRANSITION_RESULT, getCallOptions(), request);
}

/**
*/
public org.dash.platform.dapi.v0.PlatformOuterClass.GetConsensusParamsResponse getConsensusParams(org.dash.platform.dapi.v0.PlatformOuterClass.GetConsensusParamsRequest request) {
return blockingUnaryCall(
getChannel(), METHOD_GET_CONSENSUS_PARAMS, getCallOptions(), request);
}
}

/**
Expand Down Expand Up @@ -459,6 +500,14 @@ public com.google.common.util.concurrent.ListenableFuture<org.dash.platform.dapi
return futureUnaryCall(
getChannel().newCall(METHOD_WAIT_FOR_STATE_TRANSITION_RESULT, getCallOptions()), request);
}

/**
*/
public com.google.common.util.concurrent.ListenableFuture<org.dash.platform.dapi.v0.PlatformOuterClass.GetConsensusParamsResponse> getConsensusParams(
org.dash.platform.dapi.v0.PlatformOuterClass.GetConsensusParamsRequest request) {
return futureUnaryCall(
getChannel().newCall(METHOD_GET_CONSENSUS_PARAMS, getCallOptions()), request);
}
}

private static final int METHODID_BROADCAST_STATE_TRANSITION = 0;
Expand All @@ -468,6 +517,7 @@ public com.google.common.util.concurrent.ListenableFuture<org.dash.platform.dapi
private static final int METHODID_GET_IDENTITIES_BY_PUBLIC_KEY_HASHES = 4;
private static final int METHODID_GET_IDENTITY_IDS_BY_PUBLIC_KEY_HASHES = 5;
private static final int METHODID_WAIT_FOR_STATE_TRANSITION_RESULT = 6;
private static final int METHODID_GET_CONSENSUS_PARAMS = 7;

private static final class MethodHandlers<Req, Resp> implements
io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
Expand Down Expand Up @@ -514,6 +564,10 @@ public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserv
serviceImpl.waitForStateTransitionResult((org.dash.platform.dapi.v0.PlatformOuterClass.WaitForStateTransitionResultRequest) request,
(io.grpc.stub.StreamObserver<org.dash.platform.dapi.v0.PlatformOuterClass.WaitForStateTransitionResultResponse>) responseObserver);
break;
case METHODID_GET_CONSENSUS_PARAMS:
serviceImpl.getConsensusParams((org.dash.platform.dapi.v0.PlatformOuterClass.GetConsensusParamsRequest) request,
(io.grpc.stub.StreamObserver<org.dash.platform.dapi.v0.PlatformOuterClass.GetConsensusParamsResponse>) responseObserver);
break;
default:
throw new AssertionError();
}
Expand Down Expand Up @@ -554,6 +608,7 @@ public static io.grpc.ServiceDescriptor getServiceDescriptor() {
.addMethod(METHOD_GET_IDENTITIES_BY_PUBLIC_KEY_HASHES)
.addMethod(METHOD_GET_IDENTITY_IDS_BY_PUBLIC_KEY_HASHES)
.addMethod(METHOD_WAIT_FOR_STATE_TRANSITION_RESULT)
.addMethod(METHOD_GET_CONSENSUS_PARAMS)
.build();
}
}
Expand Down
40 changes: 40 additions & 0 deletions clients/platform/v0/nodejs/PlatformPromiseClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ const {
GetIdentityIdsByPublicKeyHashesResponse: PBJSGetIdentityIdsByPublicKeyHashesResponse,
WaitForStateTransitionResultRequest: PBJSWaitForStateTransitionResultRequest,
WaitForStateTransitionResultResponse: PBJSWaitForStateTransitionResultResponse,
GetConsensusParamsRequest: PBJSGetConsensusParamsRequest,
GetConsensusParamsResponse: PBJSGetConsensusParamsResponse,
},
},
},
Expand All @@ -52,6 +54,7 @@ const {
GetIdentitiesByPublicKeyHashesResponse: ProtocGetIdentitiesByPublicKeyHashesResponse,
GetIdentityIdsByPublicKeyHashesResponse: ProtocGetIdentityIdsByPublicKeyHashesResponse,
WaitForStateTransitionResultResponse: ProtocWaitForStateTransitionResultResponse,
GetConsensusParamsResponse: ProtocGetConsensusParamsResponse,
} = require('./platform_protoc');

const getPlatformDefinition = require('../../../../lib/getPlatformDefinition');
Expand Down Expand Up @@ -98,6 +101,10 @@ class PlatformPromiseClient {
this.client.waitForStateTransitionResult.bind(this.client),
);

this.client.getConsensusParams = promisify(
this.client.getConsensusParams.bind(this.client),
);

this.protocolVersion = undefined;
}

Expand Down Expand Up @@ -326,6 +333,39 @@ class PlatformPromiseClient {
);
}

/**
* @param {!GetConsensusParamsRequest} getConsensusParamsRequest
* @param {?Object<string, string>} metadata
* @param {CallOptions} [options={}]
* @returns {Promise<!GetConsensusParamsResponse>}
*/
getConsensusParams(
getConsensusParamsRequest, metadata = {}, options = {},
) {
if (!isObject(metadata)) {
throw new Error('metadata must be an object');
}

return this.client.getConsensusParams(
getConsensusParamsRequest,
convertObjectToMetadata(metadata),
{
interceptors: [
jsonToProtobufInterceptorFactory(
jsonToProtobufFactory(
ProtocGetConsensusParamsResponse,
PBJSGetConsensusParamsResponse,
),
protobufToJsonFactory(
PBJSGetConsensusParamsRequest,
),
),
],
...options,
},
);
}

/**
* @param {string} protocolVersion
*/
Expand Down
63 changes: 63 additions & 0 deletions clients/platform/v0/objective-c/Platform.pbobjc.h

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

Loading