mirror of
https://gitee.com/BTAJL/repchain.git
synced 2024-12-04 20:58:44 +08:00
repchain2.0-update70:授权索引和操作注册索引需要读取业务链和基础链的并集。
This commit is contained in:
parent
e2d13a6e87
commit
c367e50f16
@ -1,8 +1,7 @@
|
||||
package rep.authority.cache
|
||||
|
||||
import rep.app.system.RepChainSystemContext
|
||||
import rep.authority.cache.AuthenticateCache.authData
|
||||
import rep.proto.rc2.Authorize
|
||||
import rep.log.RepLogger
|
||||
import rep.sc.tpl.did.DidTplPrefix
|
||||
import rep.storage.chain.preload.BlockPreload
|
||||
import rep.utils.IdTool
|
||||
@ -38,6 +37,35 @@ class AuthenticateIndexCache(ctx : RepChainSystemContext) extends ICache(ctx) {
|
||||
IdTool.WorldStateKeySeparator + DidTplPrefix.authIdxPrefix
|
||||
}
|
||||
|
||||
override protected def readData(key: String, blockPreload: BlockPreload): Option[Any] = {
|
||||
var r = this.cache.getOrDefault(key, None)
|
||||
if (r == None) {
|
||||
RepLogger.Permission_Logger.trace(s"AuthenticateIndexCache.readData asynchronous read,from IdentityNet,key=${key}")
|
||||
//获取数据方式,0:从基础链获取;1:从业务链获取;
|
||||
val base = this.dataTypeConvert(this.db.getObject(this.getBaseNetworkPrefix + key), blockPreload)
|
||||
val business = this.dataTypeConvert(this.db.getObject(this.getBaseNetworkPrefix + key), blockPreload)
|
||||
if (base != None) {
|
||||
if (business != None) {
|
||||
val base1 = base.get.asInstanceOf[Array[String]]
|
||||
val business1 = business.get.asInstanceOf[Array[String]]
|
||||
r = Some(Array.concat(base1, business1))
|
||||
} else {
|
||||
r = base
|
||||
}
|
||||
} else {
|
||||
if (business != None) {
|
||||
r = business
|
||||
} else {
|
||||
r = None
|
||||
}
|
||||
}
|
||||
if (r != None) {
|
||||
this.cache.put(key, r)
|
||||
}
|
||||
}
|
||||
r
|
||||
}
|
||||
|
||||
def get(key:String,blockPreload: BlockPreload):Option[Array[String]]={
|
||||
val d = this.getData(key,blockPreload)
|
||||
if(d == None)
|
||||
|
@ -21,7 +21,7 @@ abstract class ICache(ctx: RepChainSystemContext) {
|
||||
config, cid.chaincodeName)
|
||||
final val business_prefix : String = KeyPrefixManager.getCustomNetKeyPrefix(
|
||||
ctx.getConfig.getChainNetworkId,cid.chaincodeName)
|
||||
final private val db = DBFactory.getDBAccess(config)
|
||||
final protected val db = DBFactory.getDBAccess(config)
|
||||
final protected val cacheMaxSize = config.getAccountCacheSize
|
||||
final protected implicit val cache = new ConcurrentLinkedHashMap.Builder[String, Option[Any]]()
|
||||
.maximumWeightedCapacity(cacheMaxSize)
|
||||
@ -39,7 +39,7 @@ abstract class ICache(ctx: RepChainSystemContext) {
|
||||
|
||||
protected def getCacheType: String
|
||||
|
||||
private def readData(key: String, blockPreload: BlockPreload): Option[Any] = {
|
||||
protected def readData(key: String, blockPreload: BlockPreload): Option[Any] = {
|
||||
val r = this.cache.getOrDefault(key, None)
|
||||
if (r == None) {
|
||||
RepLogger.Permission_Logger.trace(s"ICache.readData asynchronous read,from IdentityNet,key=${key}")
|
||||
|
@ -1,6 +1,7 @@
|
||||
package rep.authority.cache
|
||||
|
||||
import rep.app.system.RepChainSystemContext
|
||||
import rep.log.RepLogger
|
||||
import rep.sc.tpl.did.DidTplPrefix
|
||||
import rep.storage.chain.preload.BlockPreload
|
||||
import rep.utils.IdTool
|
||||
@ -36,6 +37,35 @@ class OperateIndexCache(ctx : RepChainSystemContext) extends ICache(ctx){
|
||||
IdTool.WorldStateKeySeparator + DidTplPrefix.operIdxPrefix
|
||||
}
|
||||
|
||||
override protected def readData(key: String, blockPreload: BlockPreload): Option[Any] = {
|
||||
var r = this.cache.getOrDefault(key, None)
|
||||
if (r == None) {
|
||||
RepLogger.Permission_Logger.trace(s"AuthenticateIndexCache.readData asynchronous read,from IdentityNet,key=${key}")
|
||||
//获取数据方式,0:从基础链获取;1:从业务链获取;
|
||||
val base = this.dataTypeConvert(this.db.getObject(this.getBaseNetworkPrefix + key), blockPreload)
|
||||
val business = this.dataTypeConvert(this.db.getObject(this.getBaseNetworkPrefix + key), blockPreload)
|
||||
if (base != None) {
|
||||
if (business != None) {
|
||||
val base1 = base.get.asInstanceOf[Array[String]]
|
||||
val business1 = business.get.asInstanceOf[Array[String]]
|
||||
r = Some(Array.concat(base1, business1))
|
||||
} else {
|
||||
r = base
|
||||
}
|
||||
} else {
|
||||
if (business != None) {
|
||||
r = business
|
||||
} else {
|
||||
r = None
|
||||
}
|
||||
}
|
||||
if (r != None) {
|
||||
this.cache.put(key, r)
|
||||
}
|
||||
}
|
||||
r
|
||||
}
|
||||
|
||||
def get(key:String,blockPreload: BlockPreload):Option[Array[String]]={
|
||||
val d = this.getData(key,blockPreload)
|
||||
if(d == None)
|
||||
|
Loading…
Reference in New Issue
Block a user