Skip to content

Commit a5f169a

Browse files
committed
POC gRPC node
1 parent b311bbc commit a5f169a

File tree

10 files changed

+695
-63
lines changed

10 files changed

+695
-63
lines changed

cardano-node/Setup.hs

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import Data.ProtoLens.Setup
2+
3+
main = defaultMainGeneratingProtos "proto"

cardano-node/cardano-node.cabal

+19-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,15 @@ maintainer: [email protected]
1212
license: Apache-2.0
1313
license-files: LICENSE
1414
NOTICE
15-
build-type: Simple
15+
build-type: Custom
1616
extra-doc-files: ChangeLog.md
17+
extra-source-files: proto/*.proto
18+
19+
custom-setup
20+
setup-depends:
21+
base
22+
, Cabal
23+
, proto-lens-setup
1724

1825
Flag unexpected_thunks
1926
Description: Turn on unexpected thunks checks
@@ -88,6 +95,10 @@ library
8895
Cardano.Node.Protocol.Shelley
8996
Cardano.Node.Protocol.Types
9097
Cardano.Node.Queries
98+
Cardano.Node.Rpc.Client
99+
Cardano.Node.Rpc.Proto.Api.Node
100+
Cardano.Node.Rpc.Proto.Api.NodeMetadata
101+
Cardano.Node.Rpc.Server
91102
Cardano.Node.Run
92103
Cardano.Node.Startup
93104
Cardano.Node.STM
@@ -174,6 +185,8 @@ library
174185
, ekg-core
175186
, filepath
176187
, formatting
188+
, grapesy
189+
, grpc-spec
177190
, generic-data
178191
, hashable
179192
, hostname
@@ -200,6 +213,9 @@ library
200213
, ouroboros-network-protocols ^>= 0.14
201214
, prettyprinter
202215
, prettyprinter-ansi-terminal
216+
, proto-lens-protobuf-types
217+
, proto-lens-runtime
218+
, proto-lens
203219
, psqueues
204220
, random
205221
, resource-registry
@@ -225,6 +241,8 @@ library
225241
, typed-protocols-stateful >= 0.3
226242
, yaml
227243

244+
build-tool-depends: proto-lens-protoc:proto-lens-protoc
245+
228246
executable cardano-node
229247
import: project-config
230248
hs-source-dirs: app

cardano-node/proto/node.proto

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
syntax = "proto3";
3+
4+
import "google/protobuf/empty.proto";
5+
6+
service Node {
7+
8+
rpc GetEra(google.protobuf.Empty) returns (CurrentEra) {}
9+
10+
}
11+
12+
enum Era {
13+
byron = 0;
14+
shelley = 1;
15+
allegra = 2;
16+
mary = 3;
17+
alonzo = 4;
18+
babbage = 5;
19+
conway = 6;
20+
}
21+
22+
23+
message CurrentEra {
24+
Era era = 1;
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{-# LANGUAGE DataKinds #-}
2+
{-# LANGUAGE TypeApplications #-}
3+
4+
module Cardano.Node.Rpc.Client
5+
( exampleCurrentEra
6+
7+
)
8+
where
9+
import qualified Cardano.Node.Rpc.Proto.Api.Node as ProtoGen
10+
import Data.ProtoLens (defMessage)
11+
import Data.ProtoLens.Field (field)
12+
import Lens.Micro
13+
14+
exampleCurrentEra :: ProtoGen.CurrentEra
15+
exampleCurrentEra = defMessage & field @"era" .~ ProtoGen.Byron

0 commit comments

Comments
 (0)