Skip to content

Commit

Permalink
perf(dapi)!: replace getMnListDiff with a streaming endpoint (dashp…
Browse files Browse the repository at this point in the history
  • Loading branch information
shumkov authored Jun 12, 2024
1 parent 52aff41 commit 2c9368a
Show file tree
Hide file tree
Showing 68 changed files with 2,461 additions and 548 deletions.
2 changes: 1 addition & 1 deletion .github/actions/nodejs/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ runs:
using: composite
steps:
- name: Setup Node.JS
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: "20"

Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/tests-dashmate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@ jobs:
key: build-js-artifacts/${{ github.sha }}

- name: Unpack JS build artifacts archive
run: tar -xf build-js-artifacts-${{ github.sha }}.tar
run: tar -xvf build-js-artifacts-${{ github.sha }}.tar

- name: Replace with pre-built images
run: |
set -x
# Login to ECR
DOCKER_HUB_ORG="${{ vars.AWS_ACCOUNT_ID }}.dkr.ecr.${{ vars.AWS_REGION }}.amazonaws.com"
aws ecr get-login-password --region ${{ vars.AWS_REGION }} | docker login --username AWS --password-stdin $DOCKER_HUB_ORG
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ jobs:
uses: actions/checkout@v4

- name: Setup Node.JS
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: "18"
node-version: "20"

- name: Enable corepack
run: corepack enable
Expand Down
11 changes: 7 additions & 4 deletions .pnp.cjs

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

6 changes: 3 additions & 3 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ plugins:
'DAPI-Client/getting-started/quickstart.md': 'https://docs.dash.org/projects/platform/en/stable/docs/dapi-client-js/quick-start.html'
'DAPI-Client/usage/application/DAPIClient.md': 'https://docs.dash.org/projects/platform/en/stable/docs/dapi-client-js/usage/dapiclient.html'
'DAPI-Client/usage/application/core/broadcastTransaction.md': 'https://docs.dash.org/projects/platform/en/stable/docs/dapi-client-js/usage/core/broadcasttransaction.html'
'DAPI-Client/usage/application/core/generateToAddress.md': 'https://docs.dash.org/projects/platform/en/stable/docs/dapi-client-js/usage/core/generatetoaddress.html'
'DAPI-Client/usage/application/core/getBestBlockHash.md': 'https://docs.dash.org/projects/platform/en/stable/docs/dapi-client-js/usage/core/getbestblockhash.html'
'DAPI-Client/usage/application/core/getBlockByHash.md': 'https://docs.dash.org/projects/platform/en/stable/docs/dapi-client-js/usage/core/getblockbyhash.html'
'DAPI-Client/usage/application/core/getBlockByHeight.md': 'https://docs.dash.org/projects/platform/en/stable/docs/dapi-client-js/usage/core/getblockbyheight.html'
'DAPI-Client/usage/application/core/getBlockHash.md': 'https://docs.dash.org/projects/platform/en/stable/docs/dapi-client-js/usage/core/getblockhash.html'
'DAPI-Client/usage/application/core/getMnListDiff.md': 'https://docs.dash.org/projects/platform/en/stable/docs/dapi-client-js/usage/core/getmnlistdiff.html'
'DAPI-Client/usage/application/core/getStatus.md': 'https://docs.dash.org/projects/platform/en/stable/docs/dapi-client-js/usage/core/getstatus.html'
'DAPI-Client/usage/application/core/getTransaction.md': 'https://docs.dash.org/projects/platform/en/stable/docs/dapi-client-js/usage/core/gettransaction.html'
'DAPI-Client/usage/utils/subscribeToTransactionsWithProofs.md': 'https://docs.dash.org/projects/platform/en/stable/docs/dapi-client-js/usage/core/subscribetotransactionswithproofs.html'
'DAPI-Client/usage/application/core/subscribeToTransactionsWithProofs.md': 'https://docs.dash.org/projects/platform/en/stable/docs/dapi-client-js/usage/core/subscribetotransactionswithproofs.html'
'DAPI-Client/usage/application/core/subscribeToMasternodeList.md': 'https://docs.dash.org/projects/platform/en/stable/docs/dapi-client-js/usage/core/subscribetomasternodelist.html'
'DAPI-Client/usage/application/core/subscribeToBlockHeadersWithChainLocks.md': 'https://docs.dash.org/projects/platform/en/stable/docs/dapi-client-js/usage/core/subscribetoblockheaderswithchainlocks.html'
'DAPI-Client/usage/application/platform/broadcastStateTransition.md': 'https://docs.dash.org/projects/platform/en/stable/docs/dapi-client-js/usage/platform/broadcaststatetransition.html'
'DAPI-Client/usage/application/getDataContract.md': 'https://docs.dash.org/projects/platform/en/stable/docs/dapi-client-js/usage/platform/getdatacontract.html'
'DAPI-Client/usage/application/getDocuments.md': 'https://docs.dash.org/projects/platform/en/stable/docs/dapi-client-js/usage/platform/getdocuments.html'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,37 @@ org.dash.platform.dapi.v0.CoreOuterClass.TransactionsWithProofsResponse> getSubs
return getSubscribeToTransactionsWithProofsMethod;
}

private static volatile io.grpc.MethodDescriptor<org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListRequest,
org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListResponse> getSubscribeToMasternodeListMethod;

@io.grpc.stub.annotations.RpcMethod(
fullMethodName = SERVICE_NAME + '/' + "subscribeToMasternodeList",
requestType = org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListRequest.class,
responseType = org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListResponse.class,
methodType = io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING)
public static io.grpc.MethodDescriptor<org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListRequest,
org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListResponse> getSubscribeToMasternodeListMethod() {
io.grpc.MethodDescriptor<org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListRequest, org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListResponse> getSubscribeToMasternodeListMethod;
if ((getSubscribeToMasternodeListMethod = CoreGrpc.getSubscribeToMasternodeListMethod) == null) {
synchronized (CoreGrpc.class) {
if ((getSubscribeToMasternodeListMethod = CoreGrpc.getSubscribeToMasternodeListMethod) == null) {
CoreGrpc.getSubscribeToMasternodeListMethod = getSubscribeToMasternodeListMethod =
io.grpc.MethodDescriptor.<org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListRequest, org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListResponse>newBuilder()
.setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING)
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "subscribeToMasternodeList"))
.setSampledToLocalTracing(true)
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListRequest.getDefaultInstance()))
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListResponse.getDefaultInstance()))
.setSchemaDescriptor(new CoreMethodDescriptorSupplier("subscribeToMasternodeList"))
.build();
}
}
}
return getSubscribeToMasternodeListMethod;
}

/**
* Creates a new async stub that supports all call types for the service
*/
Expand Down Expand Up @@ -405,6 +436,13 @@ public void subscribeToTransactionsWithProofs(org.dash.platform.dapi.v0.CoreOute
io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getSubscribeToTransactionsWithProofsMethod(), responseObserver);
}

/**
*/
public void subscribeToMasternodeList(org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListRequest request,
io.grpc.stub.StreamObserver<org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListResponse> responseObserver) {
io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getSubscribeToMasternodeListMethod(), responseObserver);
}

@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
.addMethod(
Expand Down Expand Up @@ -470,6 +508,13 @@ public void subscribeToTransactionsWithProofs(org.dash.platform.dapi.v0.CoreOute
org.dash.platform.dapi.v0.CoreOuterClass.TransactionsWithProofsRequest,
org.dash.platform.dapi.v0.CoreOuterClass.TransactionsWithProofsResponse>(
this, METHODID_SUBSCRIBE_TO_TRANSACTIONS_WITH_PROOFS)))
.addMethod(
getSubscribeToMasternodeListMethod(),
io.grpc.stub.ServerCalls.asyncServerStreamingCall(
new MethodHandlers<
org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListRequest,
org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListResponse>(
this, METHODID_SUBSCRIBE_TO_MASTERNODE_LIST)))
.build();
}
}
Expand Down Expand Up @@ -559,6 +604,14 @@ public void subscribeToTransactionsWithProofs(org.dash.platform.dapi.v0.CoreOute
io.grpc.stub.ClientCalls.asyncServerStreamingCall(
getChannel().newCall(getSubscribeToTransactionsWithProofsMethod(), getCallOptions()), request, responseObserver);
}

/**
*/
public void subscribeToMasternodeList(org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListRequest request,
io.grpc.stub.StreamObserver<org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListResponse> responseObserver) {
io.grpc.stub.ClientCalls.asyncServerStreamingCall(
getChannel().newCall(getSubscribeToMasternodeListMethod(), getCallOptions()), request, responseObserver);
}
}

/**
Expand Down Expand Up @@ -639,6 +692,14 @@ public java.util.Iterator<org.dash.platform.dapi.v0.CoreOuterClass.TransactionsW
return io.grpc.stub.ClientCalls.blockingServerStreamingCall(
getChannel(), getSubscribeToTransactionsWithProofsMethod(), getCallOptions(), request);
}

/**
*/
public java.util.Iterator<org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListResponse> subscribeToMasternodeList(
org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListRequest request) {
return io.grpc.stub.ClientCalls.blockingServerStreamingCall(
getChannel(), getSubscribeToMasternodeListMethod(), getCallOptions(), request);
}
}

/**
Expand Down Expand Up @@ -721,6 +782,7 @@ public com.google.common.util.concurrent.ListenableFuture<org.dash.platform.dapi
private static final int METHODID_GET_ESTIMATED_TRANSACTION_FEE = 6;
private static final int METHODID_SUBSCRIBE_TO_BLOCK_HEADERS_WITH_CHAIN_LOCKS = 7;
private static final int METHODID_SUBSCRIBE_TO_TRANSACTIONS_WITH_PROOFS = 8;
private static final int METHODID_SUBSCRIBE_TO_MASTERNODE_LIST = 9;

private static final class MethodHandlers<Req, Resp> implements
io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
Expand Down Expand Up @@ -775,6 +837,10 @@ public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserv
serviceImpl.subscribeToTransactionsWithProofs((org.dash.platform.dapi.v0.CoreOuterClass.TransactionsWithProofsRequest) request,
(io.grpc.stub.StreamObserver<org.dash.platform.dapi.v0.CoreOuterClass.TransactionsWithProofsResponse>) responseObserver);
break;
case METHODID_SUBSCRIBE_TO_MASTERNODE_LIST:
serviceImpl.subscribeToMasternodeList((org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListRequest) request,
(io.grpc.stub.StreamObserver<org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListResponse>) responseObserver);
break;
default:
throw new AssertionError();
}
Expand Down Expand Up @@ -845,6 +911,7 @@ public static io.grpc.ServiceDescriptor getServiceDescriptor() {
.addMethod(getGetEstimatedTransactionFeeMethod())
.addMethod(getSubscribeToBlockHeadersWithChainLocksMethod())
.addMethod(getSubscribeToTransactionsWithProofsMethod())
.addMethod(getSubscribeToMasternodeListMethod())
.build();
}
}
Expand Down
35 changes: 35 additions & 0 deletions packages/dapi-grpc/clients/core/v0/nodejs/CorePromiseClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ const {
GetEstimatedTransactionFeeResponse: PBJSGetEstimatedTransactionFeeResponse,
TransactionsWithProofsRequest: PBJSTransactionsWithProofsRequest,
TransactionsWithProofsResponse: PBJSTransactionsWithProofsResponse,
MasternodeListRequest: PBJSMasternodeListRequest,
MasternodeListResponse: PBJSMasternodeListResponse,
},
},
},
Expand All @@ -59,6 +61,7 @@ const {
BlockHeadersWithChainLocksResponse: ProtocBlockHeadersWithChainLocksResponse,
GetEstimatedTransactionFeeResponse: ProtocGetEstimatedTransactionFeeResponse,
TransactionsWithProofsResponse: ProtocTransactionsWithProofsResponse,
MasternodeListResponse: ProtocMasternodeListResponse,
} = require('./core_protoc');

const getCoreDefinition = require('../../../../lib/getCoreDefinition');
Expand Down Expand Up @@ -398,6 +401,38 @@ class CorePromiseClient {
},
);
}

/**
* @param {MasternodeListRequest} masternodeListRequest The request proto
* @param {?Object<string, string>} metadata User defined call metadata
* @param {CallOptions} [options={}]
* @return {!grpc.web.ClientReadableStream<!MasternodeListResponse>|undefined}
* The XHR Node Readable Stream
*/
subscribeToMasternodeList(masternodeListRequest, metadata = {}, options = {}) {
if (!isObject(metadata)) {
throw new Error('metadata must be an object');
}

return this.client.subscribeToMasternodeList(
masternodeListRequest,
convertObjectToMetadata(metadata),
{
interceptors: [
jsonToProtobufInterceptorFactory(
jsonToProtobufFactory(
ProtocMasternodeListResponse,
PBJSMasternodeListResponse,
),
protobufToJsonFactory(
PBJSMasternodeListRequest,
),
),
],
...options,
},
);
}
}

module.exports = CorePromiseClient;
Loading

0 comments on commit 2c9368a

Please sign in to comment.