@ -82,6 +82,9 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
private static final String LOCALHOST = "127.0.0.1" ;
private static final Logger LOG = LoggerFactory . getLogger ( BesuNode . class ) ;
public static final String HTTP = "http://" ;
public static final String WS_RPC = "ws-rpc" ;
public static final String JSON_RPC = "json-rpc" ;
private final Path homeDirectory ;
private KeyPair keyPair ;
@ -165,7 +168,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
}
} ) ;
keyPair . ifPresentOrElse (
( existingKeyPair ) - > {
existingKeyPair - > {
this . keyPair = existingKeyPair ;
KeyPairUtil . storeKeyFile ( existingKeyPair , homeDirectory ) ;
} ,
@ -206,7 +209,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
this . isDnsEnabled = isDnsEnabled ;
privacyParameters . ifPresent ( this : : setPrivacyParameters ) ;
this . pkiKeyStoreConfiguration = pkiKeyStoreConfiguration ;
LOG . info ( "Created BesuNode {}" , this . toString ( ) ) ;
LOG . info ( "Created BesuNode {}" , this ) ;
}
private static Path createTmpDataDirectory ( ) {
@ -281,19 +284,20 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
private Optional < String > jsonRpcBaseUrl ( ) {
if ( isJsonRpcEnabled ( ) ) {
return Optional . of (
"http://"
+ jsonRpcConfiguration . getHost ( )
+ ":"
+ portsProperties . getProperty ( "json-rpc" ) ) ;
HTTP + jsonRpcConfiguration . getHost ( ) + ":" + portsProperties . getProperty ( JSON_RPC ) ) ;
} else {
return Optional . empty ( ) ;
}
}
public Optional < String > engineHttpUrl ( ) {
if ( isJsonRpcEnabled ( ) ) {
if ( isEngineRpcEnabled ( ) ) {
final Optional < Integer > maybeEngineRpcPort = getEngineJsonRpcPort ( ) ;
if ( maybeEngineRpcPort . isEmpty ( ) ) {
return Optional . empty ( ) ;
}
return Optional . of (
"http://" + jsonRpcConfiguration . getHost ( ) + ":" + getEngineJsonRpcPort ( ) . get ( ) ) ;
HTTP + engineRpcConfiguration . get ( ) . getHost ( ) + ":" + maybeEngineRpcPort . get ( ) ) ;
} else {
return Optional . empty ( ) ;
}
@ -302,7 +306,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
private Optional < String > wsRpcBaseUrl ( ) {
if ( isWebSocketsRpcEnabled ( ) ) {
return Optional . of (
"ws://" + webSocketConfiguration . getHost ( ) + ":" + portsProperties . getProperty ( "ws-rpc" ) ) ;
"ws://" + webSocketConfiguration . getHost ( ) + ":" + portsProperties . getProperty ( WS_RPC ) ) ;
} else {
return Optional . empty ( ) ;
}
@ -311,10 +315,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
private Optional < String > wsRpcBaseHttpUrl ( ) {
if ( isWebSocketsRpcEnabled ( ) ) {
return Optional . of (
"http://"
+ webSocketConfiguration . getHost ( )
+ ":"
+ portsProperties . getProperty ( "ws-rpc" ) ) ;
HTTP + webSocketConfiguration . getHost ( ) + ":" + portsProperties . getProperty ( WS_RPC ) ) ;
} else {
return Optional . empty ( ) ;
}
@ -323,7 +324,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
public Optional < String > metricsHttpUrl ( ) {
if ( isMetricsEnabled ( ) ) {
return Optional . of (
"http://"
HTTP
+ metricsConfiguration . getHost ( )
+ ":"
+ portsProperties . getProperty ( "metrics" )
@ -336,7 +337,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
@Override
public Optional < Integer > getJsonRpcWebSocketPort ( ) {
if ( isWebSocketsRpcEnabled ( ) ) {
return Optional . of ( Integer . valueOf ( portsProperties . getProperty ( "ws-rpc" ) ) ) ;
return Optional . of ( Integer . valueOf ( portsProperties . getProperty ( WS_RPC ) ) ) ;
} else {
return Optional . empty ( ) ;
}
@ -345,7 +346,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
@Override
public Optional < Integer > getJsonRpcPort ( ) {
if ( isJsonRpcEnabled ( ) ) {
return Optional . of ( Integer . valueOf ( portsProperties . getProperty ( "json-rpc" ) ) ) ;
return Optional . of ( Integer . valueOf ( portsProperties . getProperty ( JSON_RPC ) ) ) ;
} else {
return Optional . empty ( ) ;
}
@ -396,7 +397,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
websocketService = Optional . of ( ( WebSocketService ) web3jService ) ;
} else {
final String url = jsonRpcBaseUrl ( ) . orElse ( "http://" + LOCALHOST + ":" + 8545 ) ;
final String url = jsonRpcBaseUrl ( ) . orElse ( HTTP + LOCALHOST + ":" + 8545 ) ;
web3jService = new HttpService ( url ) ;
if ( token ! = null ) {
( ( HttpService ) web3jService ) . addHeader ( "Authorization" , "Bearer " + token ) ;
@ -439,8 +440,7 @@ public class BesuNode implements NodeConfiguration, RunnableNode, AutoCloseable
baseUrl = jsonRpcBaseUrl ( ) ;
port = "8545" ;
}
loginRequestFactory =
new LoginRequestFactory ( baseUrl . orElse ( "http://" + LOCALHOST + ":" + port ) ) ;
loginRequestFactory = new LoginRequestFactory ( baseUrl . orElse ( HTTP + LOCALHOST + ":" + port ) ) ;
}
return loginRequestFactory ;
}