Skip to content

Commit 2c9368a

Browse files
authored
perf(dapi)!: replace getMnListDiff with a streaming endpoint (#1859)
1 parent 52aff41 commit 2c9368a

File tree

68 files changed

+2461
-548
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+2461
-548
lines changed

.github/actions/nodejs/action.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ runs:
55
using: composite
66
steps:
77
- name: Setup Node.JS
8-
uses: actions/setup-node@v3
8+
uses: actions/setup-node@v4
99
with:
1010
node-version: "20"
1111

.github/workflows/tests-dashmate.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,12 @@ jobs:
4949
key: build-js-artifacts/${{ github.sha }}
5050

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

5454
- name: Replace with pre-built images
5555
run: |
56+
set -x
57+
5658
# Login to ECR
5759
DOCKER_HUB_ORG="${{ vars.AWS_ACCOUNT_ID }}.dkr.ecr.${{ vars.AWS_REGION }}.amazonaws.com"
5860
aws ecr get-login-password --region ${{ vars.AWS_REGION }} | docker login --username AWS --password-stdin $DOCKER_HUB_ORG

.github/workflows/tests.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ jobs:
128128
uses: actions/checkout@v4
129129

130130
- name: Setup Node.JS
131-
uses: actions/setup-node@v3
131+
uses: actions/setup-node@v4
132132
with:
133-
node-version: "18"
133+
node-version: "20"
134134

135135
- name: Enable corepack
136136
run: corepack enable

.pnp.cjs

+7-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mkdocs.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ plugins:
4444
'DAPI-Client/getting-started/quickstart.md': 'https://docs.dash.org/projects/platform/en/stable/docs/dapi-client-js/quick-start.html'
4545
'DAPI-Client/usage/application/DAPIClient.md': 'https://docs.dash.org/projects/platform/en/stable/docs/dapi-client-js/usage/dapiclient.html'
4646
'DAPI-Client/usage/application/core/broadcastTransaction.md': 'https://docs.dash.org/projects/platform/en/stable/docs/dapi-client-js/usage/core/broadcasttransaction.html'
47-
'DAPI-Client/usage/application/core/generateToAddress.md': 'https://docs.dash.org/projects/platform/en/stable/docs/dapi-client-js/usage/core/generatetoaddress.html'
4847
'DAPI-Client/usage/application/core/getBestBlockHash.md': 'https://docs.dash.org/projects/platform/en/stable/docs/dapi-client-js/usage/core/getbestblockhash.html'
4948
'DAPI-Client/usage/application/core/getBlockByHash.md': 'https://docs.dash.org/projects/platform/en/stable/docs/dapi-client-js/usage/core/getblockbyhash.html'
5049
'DAPI-Client/usage/application/core/getBlockByHeight.md': 'https://docs.dash.org/projects/platform/en/stable/docs/dapi-client-js/usage/core/getblockbyheight.html'
5150
'DAPI-Client/usage/application/core/getBlockHash.md': 'https://docs.dash.org/projects/platform/en/stable/docs/dapi-client-js/usage/core/getblockhash.html'
52-
'DAPI-Client/usage/application/core/getMnListDiff.md': 'https://docs.dash.org/projects/platform/en/stable/docs/dapi-client-js/usage/core/getmnlistdiff.html'
5351
'DAPI-Client/usage/application/core/getStatus.md': 'https://docs.dash.org/projects/platform/en/stable/docs/dapi-client-js/usage/core/getstatus.html'
5452
'DAPI-Client/usage/application/core/getTransaction.md': 'https://docs.dash.org/projects/platform/en/stable/docs/dapi-client-js/usage/core/gettransaction.html'
55-
'DAPI-Client/usage/utils/subscribeToTransactionsWithProofs.md': 'https://docs.dash.org/projects/platform/en/stable/docs/dapi-client-js/usage/core/subscribetotransactionswithproofs.html'
53+
'DAPI-Client/usage/application/core/subscribeToTransactionsWithProofs.md': 'https://docs.dash.org/projects/platform/en/stable/docs/dapi-client-js/usage/core/subscribetotransactionswithproofs.html'
54+
'DAPI-Client/usage/application/core/subscribeToMasternodeList.md': 'https://docs.dash.org/projects/platform/en/stable/docs/dapi-client-js/usage/core/subscribetomasternodelist.html'
55+
'DAPI-Client/usage/application/core/subscribeToBlockHeadersWithChainLocks.md': 'https://docs.dash.org/projects/platform/en/stable/docs/dapi-client-js/usage/core/subscribetoblockheaderswithchainlocks.html'
5656
'DAPI-Client/usage/application/platform/broadcastStateTransition.md': 'https://docs.dash.org/projects/platform/en/stable/docs/dapi-client-js/usage/platform/broadcaststatetransition.html'
5757
'DAPI-Client/usage/application/getDataContract.md': 'https://docs.dash.org/projects/platform/en/stable/docs/dapi-client-js/usage/platform/getdatacontract.html'
5858
'DAPI-Client/usage/application/getDocuments.md': 'https://docs.dash.org/projects/platform/en/stable/docs/dapi-client-js/usage/platform/getdocuments.html'

packages/dapi-grpc/clients/core/v0/java/org/dash/platform/dapi/v0/CoreGrpc.java

+67
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,37 @@ org.dash.platform.dapi.v0.CoreOuterClass.TransactionsWithProofsResponse> getSubs
294294
return getSubscribeToTransactionsWithProofsMethod;
295295
}
296296

297+
private static volatile io.grpc.MethodDescriptor<org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListRequest,
298+
org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListResponse> getSubscribeToMasternodeListMethod;
299+
300+
@io.grpc.stub.annotations.RpcMethod(
301+
fullMethodName = SERVICE_NAME + '/' + "subscribeToMasternodeList",
302+
requestType = org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListRequest.class,
303+
responseType = org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListResponse.class,
304+
methodType = io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING)
305+
public static io.grpc.MethodDescriptor<org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListRequest,
306+
org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListResponse> getSubscribeToMasternodeListMethod() {
307+
io.grpc.MethodDescriptor<org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListRequest, org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListResponse> getSubscribeToMasternodeListMethod;
308+
if ((getSubscribeToMasternodeListMethod = CoreGrpc.getSubscribeToMasternodeListMethod) == null) {
309+
synchronized (CoreGrpc.class) {
310+
if ((getSubscribeToMasternodeListMethod = CoreGrpc.getSubscribeToMasternodeListMethod) == null) {
311+
CoreGrpc.getSubscribeToMasternodeListMethod = getSubscribeToMasternodeListMethod =
312+
io.grpc.MethodDescriptor.<org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListRequest, org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListResponse>newBuilder()
313+
.setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING)
314+
.setFullMethodName(generateFullMethodName(SERVICE_NAME, "subscribeToMasternodeList"))
315+
.setSampledToLocalTracing(true)
316+
.setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
317+
org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListRequest.getDefaultInstance()))
318+
.setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
319+
org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListResponse.getDefaultInstance()))
320+
.setSchemaDescriptor(new CoreMethodDescriptorSupplier("subscribeToMasternodeList"))
321+
.build();
322+
}
323+
}
324+
}
325+
return getSubscribeToMasternodeListMethod;
326+
}
327+
297328
/**
298329
* Creates a new async stub that supports all call types for the service
299330
*/
@@ -405,6 +436,13 @@ public void subscribeToTransactionsWithProofs(org.dash.platform.dapi.v0.CoreOute
405436
io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getSubscribeToTransactionsWithProofsMethod(), responseObserver);
406437
}
407438

439+
/**
440+
*/
441+
public void subscribeToMasternodeList(org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListRequest request,
442+
io.grpc.stub.StreamObserver<org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListResponse> responseObserver) {
443+
io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getSubscribeToMasternodeListMethod(), responseObserver);
444+
}
445+
408446
@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
409447
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
410448
.addMethod(
@@ -470,6 +508,13 @@ public void subscribeToTransactionsWithProofs(org.dash.platform.dapi.v0.CoreOute
470508
org.dash.platform.dapi.v0.CoreOuterClass.TransactionsWithProofsRequest,
471509
org.dash.platform.dapi.v0.CoreOuterClass.TransactionsWithProofsResponse>(
472510
this, METHODID_SUBSCRIBE_TO_TRANSACTIONS_WITH_PROOFS)))
511+
.addMethod(
512+
getSubscribeToMasternodeListMethod(),
513+
io.grpc.stub.ServerCalls.asyncServerStreamingCall(
514+
new MethodHandlers<
515+
org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListRequest,
516+
org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListResponse>(
517+
this, METHODID_SUBSCRIBE_TO_MASTERNODE_LIST)))
473518
.build();
474519
}
475520
}
@@ -559,6 +604,14 @@ public void subscribeToTransactionsWithProofs(org.dash.platform.dapi.v0.CoreOute
559604
io.grpc.stub.ClientCalls.asyncServerStreamingCall(
560605
getChannel().newCall(getSubscribeToTransactionsWithProofsMethod(), getCallOptions()), request, responseObserver);
561606
}
607+
608+
/**
609+
*/
610+
public void subscribeToMasternodeList(org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListRequest request,
611+
io.grpc.stub.StreamObserver<org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListResponse> responseObserver) {
612+
io.grpc.stub.ClientCalls.asyncServerStreamingCall(
613+
getChannel().newCall(getSubscribeToMasternodeListMethod(), getCallOptions()), request, responseObserver);
614+
}
562615
}
563616

564617
/**
@@ -639,6 +692,14 @@ public java.util.Iterator<org.dash.platform.dapi.v0.CoreOuterClass.TransactionsW
639692
return io.grpc.stub.ClientCalls.blockingServerStreamingCall(
640693
getChannel(), getSubscribeToTransactionsWithProofsMethod(), getCallOptions(), request);
641694
}
695+
696+
/**
697+
*/
698+
public java.util.Iterator<org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListResponse> subscribeToMasternodeList(
699+
org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListRequest request) {
700+
return io.grpc.stub.ClientCalls.blockingServerStreamingCall(
701+
getChannel(), getSubscribeToMasternodeListMethod(), getCallOptions(), request);
702+
}
642703
}
643704

644705
/**
@@ -721,6 +782,7 @@ public com.google.common.util.concurrent.ListenableFuture<org.dash.platform.dapi
721782
private static final int METHODID_GET_ESTIMATED_TRANSACTION_FEE = 6;
722783
private static final int METHODID_SUBSCRIBE_TO_BLOCK_HEADERS_WITH_CHAIN_LOCKS = 7;
723784
private static final int METHODID_SUBSCRIBE_TO_TRANSACTIONS_WITH_PROOFS = 8;
785+
private static final int METHODID_SUBSCRIBE_TO_MASTERNODE_LIST = 9;
724786

725787
private static final class MethodHandlers<Req, Resp> implements
726788
io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
@@ -775,6 +837,10 @@ public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserv
775837
serviceImpl.subscribeToTransactionsWithProofs((org.dash.platform.dapi.v0.CoreOuterClass.TransactionsWithProofsRequest) request,
776838
(io.grpc.stub.StreamObserver<org.dash.platform.dapi.v0.CoreOuterClass.TransactionsWithProofsResponse>) responseObserver);
777839
break;
840+
case METHODID_SUBSCRIBE_TO_MASTERNODE_LIST:
841+
serviceImpl.subscribeToMasternodeList((org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListRequest) request,
842+
(io.grpc.stub.StreamObserver<org.dash.platform.dapi.v0.CoreOuterClass.MasternodeListResponse>) responseObserver);
843+
break;
778844
default:
779845
throw new AssertionError();
780846
}
@@ -845,6 +911,7 @@ public static io.grpc.ServiceDescriptor getServiceDescriptor() {
845911
.addMethod(getGetEstimatedTransactionFeeMethod())
846912
.addMethod(getSubscribeToBlockHeadersWithChainLocksMethod())
847913
.addMethod(getSubscribeToTransactionsWithProofsMethod())
914+
.addMethod(getSubscribeToMasternodeListMethod())
848915
.build();
849916
}
850917
}

packages/dapi-grpc/clients/core/v0/nodejs/CorePromiseClient.js

+35
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ const {
4242
GetEstimatedTransactionFeeResponse: PBJSGetEstimatedTransactionFeeResponse,
4343
TransactionsWithProofsRequest: PBJSTransactionsWithProofsRequest,
4444
TransactionsWithProofsResponse: PBJSTransactionsWithProofsResponse,
45+
MasternodeListRequest: PBJSMasternodeListRequest,
46+
MasternodeListResponse: PBJSMasternodeListResponse,
4547
},
4648
},
4749
},
@@ -59,6 +61,7 @@ const {
5961
BlockHeadersWithChainLocksResponse: ProtocBlockHeadersWithChainLocksResponse,
6062
GetEstimatedTransactionFeeResponse: ProtocGetEstimatedTransactionFeeResponse,
6163
TransactionsWithProofsResponse: ProtocTransactionsWithProofsResponse,
64+
MasternodeListResponse: ProtocMasternodeListResponse,
6265
} = require('./core_protoc');
6366

6467
const getCoreDefinition = require('../../../../lib/getCoreDefinition');
@@ -398,6 +401,38 @@ class CorePromiseClient {
398401
},
399402
);
400403
}
404+
405+
/**
406+
* @param {MasternodeListRequest} masternodeListRequest The request proto
407+
* @param {?Object<string, string>} metadata User defined call metadata
408+
* @param {CallOptions} [options={}]
409+
* @return {!grpc.web.ClientReadableStream<!MasternodeListResponse>|undefined}
410+
* The XHR Node Readable Stream
411+
*/
412+
subscribeToMasternodeList(masternodeListRequest, metadata = {}, options = {}) {
413+
if (!isObject(metadata)) {
414+
throw new Error('metadata must be an object');
415+
}
416+
417+
return this.client.subscribeToMasternodeList(
418+
masternodeListRequest,
419+
convertObjectToMetadata(metadata),
420+
{
421+
interceptors: [
422+
jsonToProtobufInterceptorFactory(
423+
jsonToProtobufFactory(
424+
ProtocMasternodeListResponse,
425+
PBJSMasternodeListResponse,
426+
),
427+
protobufToJsonFactory(
428+
PBJSMasternodeListRequest,
429+
),
430+
),
431+
],
432+
...options,
433+
},
434+
);
435+
}
401436
}
402437

403438
module.exports = CorePromiseClient;

0 commit comments

Comments
 (0)