23
23
import io .swagger .v3 .oas .models .OpenAPI ;
24
24
import io .swagger .v3 .parser .OpenAPIV3Parser ;
25
25
import org .json .JSONObject ;
26
- import org .openapitools .client .model .* ;
26
+ import org .openapitools .client .model .Allow ;
27
27
import org .openapitools .client .model .Error ;
28
+ import org .openapitools .client .model .MetadataRequest ;
29
+ import org .openapitools .client .model .NetworkIdentifier ;
30
+ import org .openapitools .client .model .NetworkListResponse ;
31
+ import org .openapitools .client .model .NetworkOptionsResponse ;
32
+ import org .openapitools .client .model .NetworkRequest ;
33
+ import org .openapitools .client .model .NetworkStatusResponse ;
34
+ import org .openapitools .client .model .OperationStatus ;
35
+ import org .openapitools .client .model .Peer ;
36
+ import org .openapitools .client .model .Version ;
28
37
29
38
import org .cardanofoundation .rosetta .api .block .model .domain .Block ;
30
39
import org .cardanofoundation .rosetta .api .block .model .domain .GenesisBlock ;
31
40
import org .cardanofoundation .rosetta .api .block .model .domain .NetworkStatus ;
32
41
import org .cardanofoundation .rosetta .api .block .service .LedgerBlockService ;
42
+ import org .cardanofoundation .rosetta .api .network .model .Producer ;
43
+ import org .cardanofoundation .rosetta .api .network .model .PublicRoot ;
44
+ import org .cardanofoundation .rosetta .api .network .model .TopologyConfig ;
33
45
import org .cardanofoundation .rosetta .common .enumeration .OperationType ;
34
46
import org .cardanofoundation .rosetta .common .enumeration .OperationTypeStatus ;
35
47
import org .cardanofoundation .rosetta .common .exception .ExceptionFactory ;
36
48
import org .cardanofoundation .rosetta .common .mapper .DataMapper ;
37
- import org .cardanofoundation .rosetta .common .model .cardano .network .Producer ;
38
- import org .cardanofoundation .rosetta .common .model .cardano .network .PublicRoot ;
39
- import org .cardanofoundation .rosetta .common .model .cardano .network .TopologyConfig ;
40
49
import org .cardanofoundation .rosetta .common .util .Constants ;
41
50
import org .cardanofoundation .rosetta .common .util .FileUtils ;
42
51
import org .cardanofoundation .rosetta .common .util .RosettaConstants ;
@@ -67,14 +76,13 @@ public void filePathExistingValidator() {
67
76
validator (genesisPath );
68
77
}
69
78
70
- private void validator ( String path ) {
71
- if (!new File (path ).exists ()) {
79
+ private void validator (String path ) {
80
+ if (!new File (path ).exists ()) {
72
81
throw ExceptionFactory .configNotFoundException ();
73
82
}
74
83
}
75
84
76
85
77
-
78
86
@ Override
79
87
public NetworkListResponse getNetworkList (MetadataRequest metadataRequest ) {
80
88
log .info ("[networkList] Looking for all supported networks" );
@@ -127,8 +135,8 @@ public NetworkOptionsResponse getNetworkOptions(NetworkRequest networkRequest)
127
135
128
136
@ Override
129
137
public NetworkStatusResponse getNetworkStatus (NetworkRequest networkRequest )
130
- throws IOException {
131
- log .debug ("[networkStatus] Request received:" + networkRequest .toString ());
138
+ throws IOException {
139
+ log .debug ("[networkStatus] Request received: {}" , networkRequest .toString ());
132
140
log .info ("[networkStatus] Looking for latest block" );
133
141
NetworkStatus networkStatus = networkStatus ();
134
142
return datamapper .mapToNetworkStatusResponse (networkStatus );
@@ -155,13 +163,13 @@ public Network getSupportedNetwork() {
155
163
};
156
164
}
157
165
158
- private NetworkStatus networkStatus () throws IOException {
166
+ private NetworkStatus networkStatus () throws IOException {
159
167
log .info ("[networkStatus] Looking for latest block" );
160
168
Block latestBlock = ledgerBlockService .findLatestBlock ();
161
- log .debug ("[networkStatus] Latest block found " + latestBlock );
169
+ log .debug ("[networkStatus] Latest block found {}" , latestBlock );
162
170
log .debug ("[networkStatus] Looking for genesis block" );
163
171
GenesisBlock genesisBlock = ledgerBlockService .findGenesisBlock ();
164
- log .debug ("[networkStatus] Genesis block found " + genesisBlock );
172
+ log .debug ("[networkStatus] Genesis block found {}" , genesisBlock );
165
173
166
174
ObjectMapper mapper = new ObjectMapper ();
167
175
String content = FileUtils .fileReader (topologyFilepath );
@@ -179,10 +187,10 @@ private List<Peer> getPeerFromConfig(TopologyConfig topologyFile) {
179
187
List <Producer > producers = Optional .ofNullable (topologyFile ).map (
180
188
TopologyConfig ::getProducers )
181
189
.orElseGet (() -> {
182
- assert topologyFile != null ;
183
- return getPublicRoots (topologyFile .getPublicRoots ());
190
+ assert topologyFile != null ;
191
+ return getPublicRoots (topologyFile .getPublicRoots ());
184
192
});
185
- log .debug ("[getPeersFromConfig] Found " + producers .size () + " peers" );
193
+ log .debug ("[getPeersFromConfig] Found {} peers" , producers .size ());
186
194
return producers .stream ().map (producer -> new Peer (producer .getAddr (), null )).toList ();
187
195
}
188
196
0 commit comments