Update logs-oracle (#360)

* Update logs-oracle
* Install deps in docker image
This commit is contained in:
Nikolay G
2023-12-19 04:02:37 +01:00
committed by GitHub
parent 66331e23d3
commit 9c6d452efe
6 changed files with 20 additions and 19 deletions

View File

@@ -15,12 +15,14 @@ class LogsOracle(
private val log = LoggerFactory.getLogger(LogsOracle::class.java)
private var subscription: Disposable? = null
private val db = org.drpc.logsoracle.LogsOracle(config.store, config.store, config.ram_limit ?: 0L)
private val db = org.drpc.logsoracle.LogsOracle(config.store, config.ram_limit ?: 0L)
fun start() {
db.SetUpstream(config.rpc)
subscription = upstream.getHead().getFlux()
.doOnError { t -> log.warn("Failed to subscribe head for oracle", t) }
.subscribe { println(it.height); db.UpdateHeight(it.height) }
.subscribe { db.UpdateHeight(it.height) }
}
fun stop() {
@@ -31,8 +33,8 @@ class LogsOracle(
}
fun estimate(
fromBlock: Long?,
toBlock: Long?,
fromBlock: Long,
toBlock: Long,
address: List<String>,
topics: List<List<String>>,
): Mono<Long> {

View File

@@ -218,22 +218,16 @@ class EthereumLocalReader(
}
return logsOracle.estimate(fromBlock, toBlock, address, topics)
.map { it.toString().toByteArray() to null }
.map { "{\"result\":$it}".toByteArray() to null }
}
private fun parseBlockRef(blockRef: String?): Long? {
private fun parseBlockRef(blockRef: String?): Long {
when {
blockRef == null -> {
return null
}
blockRef == "latest" -> {
return head.getCurrentHeight() ?: return null
}
blockRef == "earliest" -> {
return 0
}
blockRef == "finalized" || blockRef == "safe" || blockRef == "pending" -> {
return null
blockRef == null || blockRef == "finalized" || blockRef == "safe" || blockRef == "pending" || blockRef == "latest" -> {
return head.getCurrentHeight() ?: throw Exception("couldn't get current head")
}
blockRef.startsWith("0x") -> {
val quantity = HexQuantity.from(blockRef) ?: throw IllegalArgumentException()

Binary file not shown.