Skip to content
This repository has been archived by the owner on Jan 29, 2019. It is now read-only.

Commit

Permalink
#161 Ethereum contract summary should use traces to calculate balances
Browse files Browse the repository at this point in the history
--fix cassandra contract summary save
--fix kafka ser/deser
  • Loading branch information
hleb-albau committed May 18, 2018
1 parent a03fcb3 commit df42217
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ interface EthereumUpdateContractSummaryRepository : ReactiveCrudRepository<CqlEt
smart_contract = :#{#summary.smartContract},
confirmed_total_received = :#{#summary.confirmedTotalReceived},
tx_number = :#{#summary.txNumber},
successful_operation_number = :#{#summary.successfulOpNumber},
uncle_number = :#{#summary.minedUncleNumber},
mined_block_number = :#{#summary.minedBlockNumber},
last_activity_date = :#{#summary.lastActivityDate},
Expand All @@ -48,13 +49,13 @@ interface EthereumUpdateContractSummaryRepository : ReactiveCrudRepository<CqlEt
@Consistency(value = ConsistencyLevel.LOCAL_QUORUM)
@Query("""
INSERT INTO contract_summary (hash, confirmed_balance, smart_contract,
confirmed_total_received, tx_number, uncle_number, mined_block_number,
confirmed_total_received, tx_number, successful_operation_number, uncle_number, mined_block_number,
first_activity_date, last_activity_date, version, kafka_delta_offset, kafka_delta_topic,
kafka_delta_partition, kafka_delta_offset_committed)
VALUES (:#{#summary.hash}, :#{#summary.confirmedBalance}, :#{#summary.smartContract},
:#{#summary.confirmedTotalReceived}, :#{#summary.txNumber}, :#{#summary.minedUncleNumber},
:#{#summary.minedBlockNumber}, :#{#summary.firstActivityDate}, :#{#summary.lastActivityDate},
:#{#summary.version}, :#{#summary.kafkaDeltaOffset},
:#{#summary.confirmedTotalReceived}, :#{#summary.txNumber},:#{#summary.successfulOpNumber},
:#{#summary.minedUncleNumber}, :#{#summary.minedBlockNumber}, :#{#summary.firstActivityDate},
:#{#summary.lastActivityDate}, :#{#summary.version}, :#{#summary.kafkaDeltaOffset},
:#{#summary.kafkaDeltaTopic}, :#{#summary.kafkaDeltaPartition},
false)
IF NOT EXISTS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class JsonDeserializer<T>(private val type: Class<T>) : Deserializer<T> {
private val objectMapper = jsonDeserializer
private val log = LoggerFactory.getLogger(JsonDeserializer::class.java)

//todo if exception is throwed here there is no log
override fun deserialize(topic: String, data: ByteArray): T {
log.debug("topic $topic data size : ${data.size}")
return objectMapper.readValue(data, type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ data class EthereumBlock(
val gasLimit: Long, //parsed from hex
val gasUsed: Long, //parsed from hex
val txNumber: Int,
val uncles: List<String>,
val uncles: List<String> = emptyList(),
val blockReward: BigDecimal,
val unclesReward: BigDecimal,
val txFees: BigDecimal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ data class OperationTrace(
val operation: Operation,
@JsonDeserialize(using = OperationResultDeserializer::class)
val result: OperationResult?, //null for reward and destroy contract operations
val subtraces: List<OperationTrace>
val subtraces: List<OperationTrace> = emptyList()
) {

/**
Expand Down Expand Up @@ -67,6 +67,7 @@ class OperationResultDeserializer : JsonDeserializer<OperationResult?>() {
return when {
root.has("output") -> objectMapper.convertValue(root, CallOperationResult::class.java)
root.has("code") -> objectMapper.convertValue(root, CreateContractOperationResult::class.java)
root.has("error") -> objectMapper.convertValue(root, ErroredOperationResult::class.java)
else -> throw RuntimeException("Unsupported Result")
}
}
Expand Down

0 comments on commit df42217

Please sign in to comment.