Skip to content

Commit

Permalink
Feat/manager counter
Browse files Browse the repository at this point in the history
  • Loading branch information
jsamol authored and godenzim committed Jun 13, 2024
1 parent 7d34932 commit 668cc07
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Project.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
object Project {
const val group = "com.github.acurast"
const val version = "0.1.20"
const val version = "0.1.21-beta01"
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import acurast.codec.type.marketplace.JobAssignment
import acurast.codec.type.uniques.PalletUniquesItemDetails
import acurast.rpc.engine.RpcEngine
import acurast.rpc.pallet.State
import acurast.rpc.versioned.storage.VersionedAcurastStorage
import acurast.rpc.type.FrameSystemAccountInfo
import acurast.rpc.type.PalletAssetsAssetAccount
import acurast.rpc.type.readAccountInfo
import acurast.rpc.type.readPalletAssetsAssetAccount
import acurast.rpc.versioned.storage.VersionedAcurastStorage
import java.nio.ByteBuffer

public interface V0AcurastStorage : VersionedAcurastStorage {
Expand Down Expand Up @@ -41,6 +41,12 @@ public interface V0AcurastStorage : VersionedAcurastStorage {
timeout: Long? = null,
): Int?

public suspend fun getManagerCounter(
accountId: ByteArray,
blockHash: ByteArray? = null,
timeout: Long? = null,
): ULong?

/**
* Get the registration information of a given job.
*/
Expand Down Expand Up @@ -162,6 +168,30 @@ internal open class V0AcurastStorageImpl(private val engine: RpcEngine, private
return ByteBuffer.wrap(storage.hexToBa()).readU128().toInt()
}

override suspend fun getManagerCounter(
accountId: ByteArray,
blockHash: ByteArray?,
timeout: Long?,
): ULong? {
val key =
"AcurastProcessorManager".toByteArray().xxH128() +
"ManagerCounter".toByteArray().xxH128() +
accountId.blake2b(128)

val storage = state.getStorage(
storageKey = key,
blockHash,
timeout,
engine,
)

if (storage.isNullOrEmpty()) {
return null
}

return ByteBuffer.wrap(storage.hexToBa()).readU64()
}

override suspend fun getJobRegistration(
jobIdentifier: JobIdentifier,
blockHash: ByteArray?,
Expand Down

0 comments on commit 668cc07

Please sign in to comment.