solution: actual version in RPC

fix: #73
This commit is contained in:
Igor Artamonov
2021-11-17 21:48:00 -05:00
parent acdb450fdf
commit bd25744768
4 changed files with 20 additions and 2 deletions

View File

@@ -59,6 +59,13 @@ open class Config(
init {
configFilePath = getConfigPath()
Global.version = env.getProperty("version.app", Global.version).let {
if (it.contains("SNAPSHOT")) {
listOfNotNull(it, env.getProperty("version.commit")).joinToString("-")
} else {
it
}
}
}
fun getConfigPath(): File {

View File

@@ -72,6 +72,8 @@ class Global {
@JvmStatic
val objectMapper: ObjectMapper = createObjectMapper()
var version: String = "DEV"
val control: ScheduledExecutorService = Executors.newSingleThreadScheduledExecutor()
private fun createObjectMapper(): ObjectMapper {

View File

@@ -15,6 +15,7 @@
*/
package io.emeraldpay.dshackle.upstream.calls
import io.emeraldpay.dshackle.Global
import io.emeraldpay.dshackle.quorum.AlwaysQuorum
import io.emeraldpay.dshackle.quorum.BroadcastQuorum
import io.emeraldpay.dshackle.quorum.CallQuorum
@@ -25,6 +26,11 @@ import java.util.Collections
class DefaultBitcoinMethods : CallMethods {
private val networkinfo = Global.objectMapper.writeValueAsBytes(mapOf(
"version" to 210100,
"subversion" to "/EmeraldDshackle:${Global.version}/"
))
private val freshMethods = listOf(
"getblock",
"gettransaction", "gettxout",
@@ -77,7 +83,7 @@ class DefaultBitcoinMethods : CallMethods {
override fun executeHardcoded(method: String): ByteArray {
return when (method) {
"getconnectioncount" -> "42".toByteArray()
"getnetworkinfo" -> "{\"version\": 700000, \"subversion\": \"/EmeraldDshackle:v0.9/\"}".toByteArray()
"getnetworkinfo" -> networkinfo
else -> throw RpcException(-32601, "Method not found")
}
}

View File

@@ -16,6 +16,7 @@
*/
package io.emeraldpay.dshackle.upstream.calls
import io.emeraldpay.dshackle.Global
import io.emeraldpay.dshackle.quorum.AlwaysQuorum
import io.emeraldpay.dshackle.quorum.BroadcastQuorum
import io.emeraldpay.dshackle.quorum.CallQuorum
@@ -32,6 +33,8 @@ class DefaultEthereumMethods(
private val chain: Chain
) : CallMethods {
private val version = "\"EmeraldDshackle/${Global.version}\""
private val anyResponseMethods = listOf(
"eth_gasPrice",
"eth_call",
@@ -178,7 +181,7 @@ class DefaultEthereumMethods(
"true"
}
"web3_clientVersion" -> {
"\"EmeraldDshackle/v0.9\""
version
}
"eth_protocolVersion" -> {
"\"0x3f\""