Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(zeromq): add ZMQ Publishers to NodeInfo API #1674

Merged
merged 7 commits into from
Jan 19, 2025
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
2 changes: 1 addition & 1 deletion node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func NewNode(genDoc *genesis.Genesis, conf *config.Config,
return nil, err
}

grpcServer := grpc.NewServer(conf.GRPC, state, syn, net, consMgr, walletMgr)
grpcServer := grpc.NewServer(conf.GRPC, state, syn, net, consMgr, walletMgr, zeromqServer)
httpServer := http.NewServer(conf.HTTP, enableHTTPAuth)
jsonrpcServer := jsonrpc.NewServer(conf.JSONRPC)

Expand Down
2 changes: 1 addition & 1 deletion wallet/wallet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func setup(t *testing.T) *testData {
gRPCServer := grpc.NewServer(
grpcConf, mockState,
nil, nil,
nil, wallet.NewWalletManager(walletMgrConf),
nil, wallet.NewWalletManager(walletMgrConf), nil,
)

assert.NoError(t, gRPCServer.StartServer())
Expand Down
83 changes: 83 additions & 0 deletions www/grpc/gen/dart/network.pb.dart
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ class GetNodeInfoResponse extends $pb.GeneratedMessage {
..pPS(9, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'protocols')
..a<$core.double>(13, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'clockOffset', $pb.PbFieldType.OD)
..aOM<ConnectionInfo>(14, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'connectionInfo', subBuilder: ConnectionInfo.create)
..pc<ZMQPublisherInfo>(15, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'zmqPublishers', $pb.PbFieldType.PM, subBuilder: ZMQPublisherInfo.create)
..hasRequiredFields = false
;

Expand All @@ -201,6 +202,7 @@ class GetNodeInfoResponse extends $pb.GeneratedMessage {
$core.Iterable<$core.String>? protocols,
$core.double? clockOffset,
ConnectionInfo? connectionInfo,
$core.Iterable<ZMQPublisherInfo>? zmqPublishers,
}) {
final _result = create();
if (moniker != null) {
Expand Down Expand Up @@ -236,6 +238,9 @@ class GetNodeInfoResponse extends $pb.GeneratedMessage {
if (connectionInfo != null) {
_result.connectionInfo = connectionInfo;
}
if (zmqPublishers != null) {
_result.zmqPublishers.addAll(zmqPublishers);
}
return _result;
}
factory GetNodeInfoResponse.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
Expand Down Expand Up @@ -347,6 +352,84 @@ class GetNodeInfoResponse extends $pb.GeneratedMessage {
void clearConnectionInfo() => clearField(14);
@$pb.TagNumber(14)
ConnectionInfo ensureConnectionInfo() => $_ensure(10);

@$pb.TagNumber(15)
$core.List<ZMQPublisherInfo> get zmqPublishers => $_getList(11);
}

class ZMQPublisherInfo extends $pb.GeneratedMessage {
static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'ZMQPublisherInfo', package: const $pb.PackageName(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'pactus'), createEmptyInstance: create)
..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'topic')
..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'address')
..a<$core.int>(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'hwm', $pb.PbFieldType.O3)
..hasRequiredFields = false
;

ZMQPublisherInfo._() : super();
factory ZMQPublisherInfo({
$core.String? topic,
$core.String? address,
$core.int? hwm,
}) {
final _result = create();
if (topic != null) {
_result.topic = topic;
}
if (address != null) {
_result.address = address;
}
if (hwm != null) {
_result.hwm = hwm;
}
return _result;
}
factory ZMQPublisherInfo.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
factory ZMQPublisherInfo.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.deepCopy] instead. '
'Will be removed in next major version')
ZMQPublisherInfo clone() => ZMQPublisherInfo()..mergeFromMessage(this);
@$core.Deprecated(
'Using this can add significant overhead to your binary. '
'Use [GeneratedMessageGenericExtensions.rebuild] instead. '
'Will be removed in next major version')
ZMQPublisherInfo copyWith(void Function(ZMQPublisherInfo) updates) => super.copyWith((message) => updates(message as ZMQPublisherInfo)) as ZMQPublisherInfo; // ignore: deprecated_member_use
$pb.BuilderInfo get info_ => _i;
@$core.pragma('dart2js:noInline')
static ZMQPublisherInfo create() => ZMQPublisherInfo._();
ZMQPublisherInfo createEmptyInstance() => create();
static $pb.PbList<ZMQPublisherInfo> createRepeated() => $pb.PbList<ZMQPublisherInfo>();
@$core.pragma('dart2js:noInline')
static ZMQPublisherInfo getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor<ZMQPublisherInfo>(create);
static ZMQPublisherInfo? _defaultInstance;

@$pb.TagNumber(1)
$core.String get topic => $_getSZ(0);
@$pb.TagNumber(1)
set topic($core.String v) { $_setString(0, v); }
@$pb.TagNumber(1)
$core.bool hasTopic() => $_has(0);
@$pb.TagNumber(1)
void clearTopic() => clearField(1);

@$pb.TagNumber(2)
$core.String get address => $_getSZ(1);
@$pb.TagNumber(2)
set address($core.String v) { $_setString(1, v); }
@$pb.TagNumber(2)
$core.bool hasAddress() => $_has(1);
@$pb.TagNumber(2)
void clearAddress() => clearField(2);

@$pb.TagNumber(3)
$core.int get hwm => $_getIZ(2);
@$pb.TagNumber(3)
set hwm($core.int v) { $_setSignedInt32(2, v); }
@$pb.TagNumber(3)
$core.bool hasHwm() => $_has(2);
@$pb.TagNumber(3)
void clearHwm() => clearField(3);
}

class PeerInfo extends $pb.GeneratedMessage {
Expand Down
16 changes: 15 additions & 1 deletion www/grpc/gen/dart/network.pbjson.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,24 @@ const GetNodeInfoResponse$json = const {
const {'1': 'protocols', '3': 9, '4': 3, '5': 9, '10': 'protocols'},
const {'1': 'clock_offset', '3': 13, '4': 1, '5': 1, '10': 'clockOffset'},
const {'1': 'connection_info', '3': 14, '4': 1, '5': 11, '6': '.pactus.ConnectionInfo', '10': 'connectionInfo'},
const {'1': 'zmq_publishers', '3': 15, '4': 3, '5': 11, '6': '.pactus.ZMQPublisherInfo', '10': 'zmqPublishers'},
],
};

/// Descriptor for `GetNodeInfoResponse`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List getNodeInfoResponseDescriptor = $convert.base64Decode('ChNHZXROb2RlSW5mb1Jlc3BvbnNlEhgKB21vbmlrZXIYASABKAlSB21vbmlrZXISFAoFYWdlbnQYAiABKAlSBWFnZW50EhcKB3BlZXJfaWQYAyABKAlSBnBlZXJJZBIdCgpzdGFydGVkX2F0GAQgASgEUglzdGFydGVkQXQSIgoMcmVhY2hhYmlsaXR5GAUgASgJUgxyZWFjaGFiaWxpdHkSGgoIc2VydmljZXMYBiABKAVSCHNlcnZpY2VzEiUKDnNlcnZpY2VzX25hbWVzGAcgASgJUg1zZXJ2aWNlc05hbWVzEh8KC2xvY2FsX2FkZHJzGAggAygJUgpsb2NhbEFkZHJzEhwKCXByb3RvY29scxgJIAMoCVIJcHJvdG9jb2xzEiEKDGNsb2NrX29mZnNldBgNIAEoAVILY2xvY2tPZmZzZXQSPwoPY29ubmVjdGlvbl9pbmZvGA4gASgLMhYucGFjdHVzLkNvbm5lY3Rpb25JbmZvUg5jb25uZWN0aW9uSW5mbw==');
final $typed_data.Uint8List getNodeInfoResponseDescriptor = $convert.base64Decode('ChNHZXROb2RlSW5mb1Jlc3BvbnNlEhgKB21vbmlrZXIYASABKAlSB21vbmlrZXISFAoFYWdlbnQYAiABKAlSBWFnZW50EhcKB3BlZXJfaWQYAyABKAlSBnBlZXJJZBIdCgpzdGFydGVkX2F0GAQgASgEUglzdGFydGVkQXQSIgoMcmVhY2hhYmlsaXR5GAUgASgJUgxyZWFjaGFiaWxpdHkSGgoIc2VydmljZXMYBiABKAVSCHNlcnZpY2VzEiUKDnNlcnZpY2VzX25hbWVzGAcgASgJUg1zZXJ2aWNlc05hbWVzEh8KC2xvY2FsX2FkZHJzGAggAygJUgpsb2NhbEFkZHJzEhwKCXByb3RvY29scxgJIAMoCVIJcHJvdG9jb2xzEiEKDGNsb2NrX29mZnNldBgNIAEoAVILY2xvY2tPZmZzZXQSPwoPY29ubmVjdGlvbl9pbmZvGA4gASgLMhYucGFjdHVzLkNvbm5lY3Rpb25JbmZvUg5jb25uZWN0aW9uSW5mbxI/Cg56bXFfcHVibGlzaGVycxgPIAMoCzIYLnBhY3R1cy5aTVFQdWJsaXNoZXJJbmZvUg16bXFQdWJsaXNoZXJz');
@$core.Deprecated('Use zMQPublisherInfoDescriptor instead')
const ZMQPublisherInfo$json = const {
'1': 'ZMQPublisherInfo',
'2': const [
const {'1': 'topic', '3': 1, '4': 1, '5': 9, '10': 'topic'},
const {'1': 'address', '3': 2, '4': 1, '5': 9, '10': 'address'},
const {'1': 'hwm', '3': 3, '4': 1, '5': 5, '10': 'hwm'},
],
};

/// Descriptor for `ZMQPublisherInfo`. Decode as a `google.protobuf.DescriptorProto`.
final $typed_data.Uint8List zMQPublisherInfoDescriptor = $convert.base64Decode('ChBaTVFQdWJsaXNoZXJJbmZvEhQKBXRvcGljGAEgASgJUgV0b3BpYxIYCgdhZGRyZXNzGAIgASgJUgdhZGRyZXNzEhAKA2h3bRgDIAEoBVIDaHdt');
@$core.Deprecated('Use peerInfoDescriptor instead')
const PeerInfo$json = const {
'1': 'PeerInfo',
Expand Down Expand Up @@ -162,6 +175,7 @@ const $core.Map<$core.String, $core.Map<$core.String, $core.dynamic>> NetworkSer
'.pactus.GetNodeInfoRequest': GetNodeInfoRequest$json,
'.pactus.GetNodeInfoResponse': GetNodeInfoResponse$json,
'.pactus.ConnectionInfo': ConnectionInfo$json,
'.pactus.ZMQPublisherInfo': ZMQPublisherInfo$json,
};

/// Descriptor for `Network`. Decode as a `google.protobuf.ServiceDescriptorProto`.
Expand Down
29 changes: 29 additions & 0 deletions www/grpc/gen/docs/grpc.md
Original file line number Diff line number Diff line change
Expand Up @@ -2631,6 +2631,35 @@ Message has no fields.
<td>
Number of outbound connections.
</td>
</tr>
<tr>
<td class="fw-bold">zmq_publishers</td>
<td>repeated ZMQPublisherInfo</td>
<td>
List of active ZeroMQ publishers.
</td>
</tr>
<tr>
<td class="fw-bold">zmq_publishers[].topic</td>
<td> string</td>
<td>
The topic associated with the publisher.
</td>
</tr>
<tr>
<td class="fw-bold">zmq_publishers[].address</td>
<td> string</td>
<td>
The address of the publisher.
</td>
</tr>
<tr>
<td class="fw-bold">zmq_publishers[].hwm</td>
<td> int32</td>
<td>
The high-water mark (HWM) for the publisher, indicating the
maximum number of messages to queue before dropping older ones.
</td>
</tr>
</tbody>
</table>
Expand Down
29 changes: 29 additions & 0 deletions www/grpc/gen/docs/json-rpc.md
Original file line number Diff line number Diff line change
Expand Up @@ -2682,6 +2682,35 @@ Parameters has no fields.
<td>
Number of outbound connections.
</td>
</tr>
<tr>
<td class="fw-bold">zmq_publishers</td>
<td>repeated object</td>
<td>
List of active ZeroMQ publishers.
</td>
</tr>
<tr>
<td class="fw-bold">zmq_publishers[].topic</td>
<td> string</td>
<td>
The topic associated with the publisher.
</td>
</tr>
<tr>
<td class="fw-bold">zmq_publishers[].address</td>
<td> string</td>
<td>
The address of the publisher.
</td>
</tr>
<tr>
<td class="fw-bold">zmq_publishers[].hwm</td>
<td> numeric</td>
<td>
The high-water mark (HWM) for the publisher, indicating the
maximum number of messages to queue before dropping older ones.
</td>
</tr>
</tbody>
</table>
Expand Down
Loading
Loading