Update logs-oracle (#360)
* Update logs-oracle * Install deps in docker image
This commit is contained in:
@@ -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> {
|
||||
|
||||
@@ -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.
Reference in New Issue
Block a user