UpdatePermission exports the update permission interface for test.
(dbID proto.DatabaseID, user proto.AccountAddress, permStat *types.PermStat)
| 324 | |
| 325 | // UpdatePermission exports the update permission interface for test. |
| 326 | func (dbms *DBMS) UpdatePermission(dbID proto.DatabaseID, user proto.AccountAddress, permStat *types.PermStat) (err error) { |
| 327 | dbms.busService.lock.Lock() |
| 328 | defer dbms.busService.lock.Unlock() |
| 329 | profile, ok := dbms.busService.sqlChainProfiles[dbID] |
| 330 | if !ok { |
| 331 | dbms.busService.sqlChainProfiles[dbID] = &types.SQLChainProfile{ |
| 332 | ID: dbID, |
| 333 | Users: []*types.SQLChainUser{ |
| 334 | &types.SQLChainUser{ |
| 335 | Address: user, |
| 336 | Permission: permStat.Permission, |
| 337 | Status: permStat.Status, |
| 338 | }, |
| 339 | }, |
| 340 | } |
| 341 | } else { |
| 342 | exist := false |
| 343 | for _, u := range profile.Users { |
| 344 | if u.Address == user { |
| 345 | u.Permission = permStat.Permission |
| 346 | u.Status = permStat.Status |
| 347 | exist = true |
| 348 | break |
| 349 | } |
| 350 | } |
| 351 | if !exist { |
| 352 | profile.Users = append(profile.Users, &types.SQLChainUser{ |
| 353 | Address: user, |
| 354 | Permission: permStat.Permission, |
| 355 | Status: permStat.Status, |
| 356 | }) |
| 357 | dbms.busService.sqlChainProfiles[dbID] = profile |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | _, ok = dbms.busService.sqlChainState[dbID] |
| 362 | if !ok { |
| 363 | dbms.busService.sqlChainState[dbID] = make(map[proto.AccountAddress]*types.PermStat) |
| 364 | } |
| 365 | dbms.busService.sqlChainState[dbID][user] = permStat |
| 366 | |
| 367 | return |
| 368 | } |
| 369 | |
| 370 | func (dbms *DBMS) initDatabases( |
| 371 | meta *DBMSMeta, profiles map[proto.DatabaseID]*types.SQLChainProfile) (err error, |
no outgoing calls