index.ts 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  1. /*
  2. eslint-disable @typescript-eslint/naming-convention
  3. */
  4. import { EventContext, StoreContext } from '@joystream/hydra-common'
  5. import { Storage } from '../generated/types/storage'
  6. import {
  7. DistributionBucket,
  8. DistributionBucketFamily,
  9. DistributionBucketOperator,
  10. DistributionBucketOperatorMetadata,
  11. DistributionBucketOperatorStatus,
  12. NodeLocationMetadata,
  13. StorageBag,
  14. StorageBucket,
  15. StorageBucketOperatorStatusActive,
  16. StorageBucketOperatorStatusInvited,
  17. StorageBucketOperatorStatusMissing,
  18. StorageDataObject,
  19. StorageSystemParameters,
  20. GeoCoordinates,
  21. StorageBagDistributionAssignment,
  22. StorageBagStorageAssignment,
  23. } from 'query-node/dist/model'
  24. import BN from 'bn.js'
  25. import { getById } from '../common'
  26. import { In } from 'typeorm'
  27. import {
  28. processDistributionBucketFamilyMetadata,
  29. processDistributionOperatorMetadata,
  30. processStorageOperatorMetadata,
  31. } from './metadata'
  32. import {
  33. createDataObjects,
  34. getStorageSystem,
  35. removeDataObject,
  36. getStorageBucketWithOperatorMetadata,
  37. getBag,
  38. getDynamicBagId,
  39. getDynamicBagOwner,
  40. getDataObjectsInBag,
  41. getDynamicBag,
  42. getDistributionBucketFamilyWithMetadata,
  43. getDistributionBucketOperatorWithMetadata,
  44. } from './utils'
  45. // STORAGE BUCKETS
  46. export async function storage_StorageBucketCreated({ event, store }: EventContext & StoreContext): Promise<void> {
  47. const [
  48. bucketId,
  49. invitedWorkerId,
  50. acceptingNewBags,
  51. dataObjectSizeLimit,
  52. dataObjectCountLimit,
  53. ] = new Storage.StorageBucketCreatedEvent(event).params
  54. const storageBucket = new StorageBucket({
  55. id: bucketId.toString(),
  56. acceptingNewBags: acceptingNewBags.isTrue,
  57. dataObjectCountLimit: new BN(dataObjectCountLimit.toString()),
  58. dataObjectsSizeLimit: new BN(dataObjectSizeLimit.toString()),
  59. dataObjectsCount: new BN(0),
  60. dataObjectsSize: new BN(0),
  61. })
  62. if (invitedWorkerId.isSome) {
  63. const operatorStatus = new StorageBucketOperatorStatusInvited()
  64. operatorStatus.workerId = invitedWorkerId.unwrap().toNumber()
  65. storageBucket.operatorStatus = operatorStatus
  66. } else {
  67. storageBucket.operatorStatus = new StorageBucketOperatorStatusMissing()
  68. }
  69. await store.save<StorageBucket>(storageBucket)
  70. }
  71. export async function storage_StorageOperatorMetadataSet({ event, store }: EventContext & StoreContext): Promise<void> {
  72. const [bucketId, , metadataBytes] = new Storage.StorageOperatorMetadataSetEvent(event).params
  73. const storageBucket = await getStorageBucketWithOperatorMetadata(store, bucketId.toString())
  74. storageBucket.operatorMetadata = await processStorageOperatorMetadata(
  75. store,
  76. storageBucket.operatorMetadata,
  77. metadataBytes
  78. )
  79. await store.save<StorageBucket>(storageBucket)
  80. }
  81. export async function storage_StorageBucketStatusUpdated({ event, store }: EventContext & StoreContext): Promise<void> {
  82. const [bucketId, acceptingNewBags] = new Storage.StorageBucketStatusUpdatedEvent(event).params
  83. const storageBucket = await getById(store, StorageBucket, bucketId.toString())
  84. storageBucket.acceptingNewBags = acceptingNewBags.isTrue
  85. await store.save<StorageBucket>(storageBucket)
  86. }
  87. export async function storage_StorageBucketInvitationAccepted({
  88. event,
  89. store,
  90. }: EventContext & StoreContext): Promise<void> {
  91. const [bucketId, workerId] = new Storage.StorageBucketInvitationAcceptedEvent(event).params
  92. const storageBucket = await getById(store, StorageBucket, bucketId.toString())
  93. const operatorStatus = new StorageBucketOperatorStatusActive()
  94. operatorStatus.workerId = workerId.toNumber()
  95. storageBucket.operatorStatus = operatorStatus
  96. await store.save<StorageBucket>(storageBucket)
  97. }
  98. export async function storage_StorageBucketInvitationCancelled({
  99. event,
  100. store,
  101. }: EventContext & StoreContext): Promise<void> {
  102. const [bucketId] = new Storage.StorageBucketInvitationCancelledEvent(event).params
  103. const storageBucket = await getById(store, StorageBucket, bucketId.toString())
  104. const operatorStatus = new StorageBucketOperatorStatusMissing()
  105. storageBucket.operatorStatus = operatorStatus
  106. await store.save<StorageBucket>(storageBucket)
  107. }
  108. export async function storage_StorageBucketOperatorInvited({
  109. event,
  110. store,
  111. }: EventContext & StoreContext): Promise<void> {
  112. const [bucketId, workerId] = new Storage.StorageBucketOperatorInvitedEvent(event).params
  113. const storageBucket = await getById(store, StorageBucket, bucketId.toString())
  114. const operatorStatus = new StorageBucketOperatorStatusInvited()
  115. operatorStatus.workerId = workerId.toNumber()
  116. storageBucket.operatorStatus = operatorStatus
  117. await store.save<StorageBucket>(storageBucket)
  118. }
  119. export async function storage_StorageBucketOperatorRemoved({
  120. event,
  121. store,
  122. }: EventContext & StoreContext): Promise<void> {
  123. const [bucketId] = new Storage.StorageBucketInvitationCancelledEvent(event).params
  124. const storageBucket = await getById(store, StorageBucket, bucketId.toString())
  125. const operatorStatus = new StorageBucketOperatorStatusMissing()
  126. storageBucket.operatorStatus = operatorStatus
  127. await store.save<StorageBucket>(storageBucket)
  128. }
  129. export async function storage_StorageBucketsUpdatedForBag({
  130. event,
  131. store,
  132. }: EventContext & StoreContext): Promise<void> {
  133. const [bagId, addedBucketsIds, removedBucketsIds] = new Storage.StorageBucketsUpdatedForBagEvent(event).params
  134. // Get or create bag
  135. const storageBag = await getBag(store, bagId)
  136. const assignmentsToRemove = await store.getMany(StorageBagStorageAssignment, {
  137. where: {
  138. storageBag,
  139. storageBucket: { id: In(Array.from(removedBucketsIds).map((bucketId) => bucketId.toString())) },
  140. },
  141. })
  142. const assignmentsToAdd = Array.from(addedBucketsIds).map(
  143. (bucketId) =>
  144. new StorageBagStorageAssignment({
  145. id: `${storageBag.id}-${bucketId.toString()}`,
  146. storageBag,
  147. storageBucket: new StorageBucket({ id: bucketId.toString() }),
  148. })
  149. )
  150. await Promise.all(assignmentsToRemove.map((a) => store.remove<StorageBagStorageAssignment>(a)))
  151. await Promise.all(assignmentsToAdd.map((a) => store.save<StorageBagStorageAssignment>(a)))
  152. }
  153. export async function storage_VoucherChanged({ event, store }: EventContext & StoreContext): Promise<void> {
  154. const [bucketId, voucher] = new Storage.VoucherChangedEvent(event).params
  155. const bucket = await getById(store, StorageBucket, bucketId.toString())
  156. bucket.dataObjectCountLimit = voucher.objectsLimit
  157. bucket.dataObjectsSizeLimit = voucher.sizeLimit
  158. bucket.dataObjectsCount = voucher.objectsUsed
  159. bucket.dataObjectsSize = voucher.sizeUsed
  160. await store.save<StorageBucket>(bucket)
  161. }
  162. export async function storage_StorageBucketVoucherLimitsSet({
  163. event,
  164. store,
  165. }: EventContext & StoreContext): Promise<void> {
  166. const [bucketId, sizeLimit, countLimit] = new Storage.StorageBucketVoucherLimitsSetEvent(event).params
  167. const bucket = await getById(store, StorageBucket, bucketId.toString())
  168. bucket.dataObjectsSizeLimit = sizeLimit
  169. bucket.dataObjectCountLimit = countLimit
  170. await store.save<StorageBucket>(bucket)
  171. }
  172. export async function storage_StorageBucketDeleted({ event, store }: EventContext & StoreContext): Promise<void> {
  173. const [bucketId] = new Storage.StorageBucketDeletedEvent(event).params
  174. // TODO: Cascade remove on db level (would require changes in Hydra / comitting autogenerated files)
  175. const assignments = await store.getMany(StorageBagStorageAssignment, {
  176. where: { storageBucket: { id: bucketId.toString() } },
  177. })
  178. await Promise.all(assignments.map((a) => store.remove<StorageBagStorageAssignment>(a)))
  179. await store.remove<StorageBucket>(new StorageBucket({ id: bucketId.toString() }))
  180. }
  181. // DYNAMIC BAGS
  182. export async function storage_DynamicBagCreated({ event, store }: EventContext & StoreContext): Promise<void> {
  183. const [bagId, , storageBucketIdsSet, distributionBucketIdsSet] = new Storage.DynamicBagCreatedEvent(event).params
  184. const storageBag = new StorageBag({
  185. id: getDynamicBagId(bagId),
  186. owner: getDynamicBagOwner(bagId),
  187. })
  188. const storageAssignments = Array.from(storageBucketIdsSet).map(
  189. (bucketId) =>
  190. new StorageBagStorageAssignment({
  191. id: `${storageBag.id}-${bucketId.toString()}`,
  192. storageBag,
  193. storageBucket: new StorageBucket({ id: bucketId.toString() }),
  194. })
  195. )
  196. const distributionAssignments = Array.from(distributionBucketIdsSet).map(
  197. (bucketId) =>
  198. new StorageBagDistributionAssignment({
  199. id: `${storageBag.id}-${bucketId.toString()}`,
  200. storageBag,
  201. distributionBucket: new DistributionBucket({ id: bucketId.toString() }),
  202. })
  203. )
  204. await store.save<StorageBag>(storageBag)
  205. await Promise.all(storageAssignments.map((a) => store.save<StorageBagStorageAssignment>(a)))
  206. await Promise.all(distributionAssignments.map((a) => store.save<StorageBagDistributionAssignment>(a)))
  207. }
  208. export async function storage_DynamicBagDeleted({ event, store }: EventContext & StoreContext): Promise<void> {
  209. const [, bagId] = new Storage.DynamicBagDeletedEvent(event).params
  210. const storageBag = await getDynamicBag(store, bagId, ['objects'])
  211. // TODO: Cascade remove on db level (would require changes in Hydra / comitting autogenerated files)
  212. const storageAssignments = await store.getMany(StorageBagStorageAssignment, { where: { storageBag } })
  213. const distributionAssignments = await store.getMany(StorageBagDistributionAssignment, { where: { storageBag } })
  214. await Promise.all(storageAssignments.map((a) => store.remove<StorageBagStorageAssignment>(a)))
  215. await Promise.all(distributionAssignments.map((a) => store.remove<StorageBagDistributionAssignment>(a)))
  216. await store.remove<StorageBag>(storageBag)
  217. }
  218. // DATA OBJECTS
  219. // Note: "Uploaded" here actually means "created" (the real upload happens later)
  220. export async function storage_DataObjectsUploaded({ event, store }: EventContext & StoreContext): Promise<void> {
  221. const [dataObjectIds, uploadParams, deletionPrize] = new Storage.DataObjectsUploadedEvent(event).params
  222. await createDataObjects(store, uploadParams, deletionPrize, dataObjectIds)
  223. }
  224. export async function storage_PendingDataObjectsAccepted({ event, store }: EventContext & StoreContext): Promise<void> {
  225. const [, , bagId, dataObjectIds] = new Storage.PendingDataObjectsAcceptedEvent(event).params
  226. const dataObjects = await getDataObjectsInBag(store, bagId, dataObjectIds)
  227. await Promise.all(
  228. dataObjects.map(async (dataObject) => {
  229. dataObject.isAccepted = true
  230. await store.save<StorageDataObject>(dataObject)
  231. })
  232. )
  233. }
  234. export async function storage_DataObjectsMoved({ event, store }: EventContext & StoreContext): Promise<void> {
  235. const [srcBagId, destBagId, dataObjectIds] = new Storage.DataObjectsMovedEvent(event).params
  236. const dataObjects = await getDataObjectsInBag(store, srcBagId, dataObjectIds)
  237. const destBag = await getBag(store, destBagId)
  238. await Promise.all(
  239. dataObjects.map(async (dataObject) => {
  240. dataObject.storageBag = destBag
  241. await store.save<StorageDataObject>(dataObject)
  242. })
  243. )
  244. }
  245. export async function storage_DataObjectsDeleted({ event, store }: EventContext & StoreContext): Promise<void> {
  246. const [, bagId, dataObjectIds] = new Storage.DataObjectsDeletedEvent(event).params
  247. const dataObjects = await getDataObjectsInBag(store, bagId, dataObjectIds)
  248. await Promise.all(dataObjects.map((o) => removeDataObject(store, o)))
  249. }
  250. // DISTRIBUTION FAMILY
  251. export async function storage_DistributionBucketFamilyCreated({
  252. event,
  253. store,
  254. }: EventContext & StoreContext): Promise<void> {
  255. const [familyId] = new Storage.DistributionBucketFamilyCreatedEvent(event).params
  256. const family = new DistributionBucketFamily({
  257. id: familyId.toString(),
  258. })
  259. await store.save<DistributionBucketFamily>(family)
  260. }
  261. export async function storage_DistributionBucketFamilyMetadataSet({
  262. event,
  263. store,
  264. }: EventContext & StoreContext): Promise<void> {
  265. const [familyId, metadataBytes] = new Storage.DistributionBucketFamilyMetadataSetEvent(event).params
  266. const family = await getDistributionBucketFamilyWithMetadata(store, familyId.toString())
  267. family.metadata = await processDistributionBucketFamilyMetadata(store, family.metadata, metadataBytes)
  268. await store.save<DistributionBucketFamily>(family)
  269. }
  270. export async function storage_DistributionBucketFamilyDeleted({
  271. event,
  272. store,
  273. }: EventContext & StoreContext): Promise<void> {
  274. const [familyId] = new Storage.DistributionBucketFamilyDeletedEvent(event).params
  275. const family = await getById(store, DistributionBucketFamily, familyId.toString())
  276. await store.remove(family)
  277. }
  278. // DISTRIBUTION BUCKET
  279. export async function storage_DistributionBucketCreated({ event, store }: EventContext & StoreContext): Promise<void> {
  280. const [familyId, acceptingNewBags, bucketId] = new Storage.DistributionBucketCreatedEvent(event).params
  281. const family = await getById(store, DistributionBucketFamily, familyId.toString())
  282. const bucket = new DistributionBucket({
  283. id: bucketId.toString(),
  284. acceptingNewBags: acceptingNewBags.valueOf(),
  285. distributing: true, // Runtime default
  286. family,
  287. })
  288. await store.save<DistributionBucket>(bucket)
  289. }
  290. export async function storage_DistributionBucketStatusUpdated({
  291. event,
  292. store,
  293. }: EventContext & StoreContext): Promise<void> {
  294. const [, bucketId, acceptingNewBags] = new Storage.DistributionBucketStatusUpdatedEvent(event).params
  295. const bucket = await getById(store, DistributionBucket, bucketId.toString())
  296. bucket.acceptingNewBags = acceptingNewBags.valueOf()
  297. await store.save<DistributionBucket>(bucket)
  298. }
  299. export async function storage_DistributionBucketDeleted({ event, store }: EventContext & StoreContext): Promise<void> {
  300. const [, bucketId] = new Storage.DistributionBucketDeletedEvent(event).params
  301. // TODO: Cascade remove on db level (would require changes in Hydra / comitting autogenerated files)
  302. const assignments = await store.getMany(StorageBagDistributionAssignment, {
  303. where: { distributionBucket: { id: bucketId.toString() } },
  304. })
  305. await Promise.all(assignments.map((a) => store.remove<StorageBagDistributionAssignment>(a)))
  306. await store.remove<DistributionBucket>(new DistributionBucket({ id: bucketId.toString() }))
  307. }
  308. export async function storage_DistributionBucketsUpdatedForBag({
  309. event,
  310. store,
  311. }: EventContext & StoreContext): Promise<void> {
  312. const [bagId, , addedBucketsIds, removedBucketsIds] = new Storage.DistributionBucketsUpdatedForBagEvent(event).params
  313. // Get or create bag
  314. const storageBag = await getBag(store, bagId)
  315. const assignmentsToRemove = await store.getMany(StorageBagDistributionAssignment, {
  316. where: {
  317. storageBag,
  318. distributionBucket: { id: In(Array.from(removedBucketsIds).map((bucketId) => bucketId.toString())) },
  319. },
  320. })
  321. const assignmentsToAdd = Array.from(addedBucketsIds).map(
  322. (bucketId) =>
  323. new StorageBagDistributionAssignment({
  324. id: `${storageBag.id}-${bucketId.toString()}`,
  325. storageBag,
  326. distributionBucket: new DistributionBucket({ id: bucketId.toString() }),
  327. })
  328. )
  329. await Promise.all(assignmentsToRemove.map((a) => store.remove<StorageBagDistributionAssignment>(a)))
  330. await Promise.all(assignmentsToAdd.map((a) => store.save<StorageBagDistributionAssignment>(a)))
  331. }
  332. export async function storage_DistributionBucketModeUpdated({
  333. event,
  334. store,
  335. }: EventContext & StoreContext): Promise<void> {
  336. const [, bucketId, distributing] = new Storage.DistributionBucketModeUpdatedEvent(event).params
  337. const bucket = await getById(store, DistributionBucket, bucketId.toString())
  338. bucket.distributing = distributing.valueOf()
  339. await store.save<DistributionBucket>(bucket)
  340. }
  341. export async function storage_DistributionBucketOperatorInvited({
  342. event,
  343. store,
  344. }: EventContext & StoreContext): Promise<void> {
  345. const [, bucketId, workerId] = new Storage.DistributionBucketOperatorInvitedEvent(event).params
  346. const bucket = await getById(store, DistributionBucket, bucketId.toString())
  347. const invitedOperator = new DistributionBucketOperator({
  348. id: `${bucketId}-${workerId}`,
  349. distributionBucket: bucket,
  350. status: DistributionBucketOperatorStatus.INVITED,
  351. workerId: workerId.toNumber(),
  352. })
  353. await store.save<DistributionBucketOperator>(invitedOperator)
  354. }
  355. export async function storage_DistributionBucketInvitationCancelled({
  356. event,
  357. store,
  358. }: EventContext & StoreContext): Promise<void> {
  359. const [, bucketId, workerId] = new Storage.DistributionBucketOperatorInvitedEvent(event).params
  360. const invitedOperator = await getById(store, DistributionBucketOperator, `${bucketId}-${workerId}`)
  361. await store.remove<DistributionBucketOperator>(invitedOperator)
  362. }
  363. export async function storage_DistributionBucketInvitationAccepted({
  364. event,
  365. store,
  366. }: EventContext & StoreContext): Promise<void> {
  367. const [workerId, , bucketId] = new Storage.DistributionBucketInvitationAcceptedEvent(event).params
  368. const invitedOperator = await getById(store, DistributionBucketOperator, `${bucketId}-${workerId}`)
  369. invitedOperator.status = DistributionBucketOperatorStatus.ACTIVE
  370. await store.save<DistributionBucketOperator>(invitedOperator)
  371. }
  372. export async function storage_DistributionBucketMetadataSet({
  373. event,
  374. store,
  375. }: EventContext & StoreContext): Promise<void> {
  376. const [workerId, , bucketId, metadataBytes] = new Storage.DistributionBucketMetadataSetEvent(event).params
  377. const operator = await getDistributionBucketOperatorWithMetadata(store, `${bucketId}-${workerId}`)
  378. operator.metadata = await processDistributionOperatorMetadata(store, operator.metadata, metadataBytes)
  379. await store.save<DistributionBucketOperator>(operator)
  380. }
  381. export async function storage_DistributionBucketOperatorRemoved({
  382. event,
  383. store,
  384. }: EventContext & StoreContext): Promise<void> {
  385. const [, bucketId, workerId] = new Storage.DistributionBucketOperatorRemovedEvent(event).params
  386. // TODO: Cascade remove on db level (would require changes in Hydra / comitting autogenerated files)
  387. const operator = await getDistributionBucketOperatorWithMetadata(store, `${bucketId}-${workerId}`)
  388. await store.remove<DistributionBucketOperator>(operator)
  389. if (operator.metadata) {
  390. await store.remove<DistributionBucketOperatorMetadata>(operator.metadata)
  391. if (operator.metadata.nodeLocation) {
  392. await store.remove<NodeLocationMetadata>(operator.metadata.nodeLocation)
  393. if (operator.metadata.nodeLocation.coordinates) {
  394. await store.remove<GeoCoordinates>(operator.metadata.nodeLocation.coordinates)
  395. }
  396. }
  397. }
  398. }
  399. // STORAGE SYSTEM GLOBAL PARAMS
  400. export async function storage_UpdateBlacklist({ event, store }: EventContext & StoreContext): Promise<void> {
  401. const [removedContentIds, addedContentIds] = new Storage.UpdateBlacklistEvent(event).params
  402. const storageSystem = await getStorageSystem(store)
  403. storageSystem.blacklist = storageSystem.blacklist
  404. .filter((cid) => !Array.from(removedContentIds).some((id) => id.eq(cid)))
  405. .concat(Array.from(addedContentIds).map((id) => id.toString()))
  406. await store.save<StorageSystemParameters>(storageSystem)
  407. }
  408. export async function storage_DistributionBucketsPerBagLimitUpdated({
  409. event,
  410. store,
  411. }: EventContext & StoreContext): Promise<void> {
  412. const [newLimit] = new Storage.DistributionBucketsPerBagLimitUpdatedEvent(event).params
  413. const storageSystem = await getStorageSystem(store)
  414. storageSystem.distributionBucketsPerBagLimit = newLimit.toNumber()
  415. await store.save<StorageSystemParameters>(storageSystem)
  416. }
  417. export async function storage_StorageBucketsPerBagLimitUpdated({
  418. event,
  419. store,
  420. }: EventContext & StoreContext): Promise<void> {
  421. const [newLimit] = new Storage.StorageBucketsPerBagLimitUpdatedEvent(event).params
  422. const storageSystem = await getStorageSystem(store)
  423. storageSystem.storageBucketsPerBagLimit = newLimit.toNumber()
  424. await store.save<StorageSystemParameters>(storageSystem)
  425. }
  426. export async function storage_StorageBucketsVoucherMaxLimitsUpdated({
  427. event,
  428. store,
  429. }: EventContext & StoreContext): Promise<void> {
  430. const [sizeLimit, countLimit] = new Storage.StorageBucketsVoucherMaxLimitsUpdatedEvent(event).params
  431. const storageSystem = await getStorageSystem(store)
  432. storageSystem.storageBucketMaxObjectsSizeLimit = sizeLimit
  433. storageSystem.storageBucketMaxObjectsCountLimit = countLimit
  434. await store.save<StorageSystemParameters>(storageSystem)
  435. }
  436. export async function storage_UploadingBlockStatusUpdated({
  437. event,
  438. store,
  439. }: EventContext & StoreContext): Promise<void> {
  440. const [isBlocked] = new Storage.UploadingBlockStatusUpdatedEvent(event).params
  441. const storageSystem = await getStorageSystem(store)
  442. storageSystem.uploadingBlocked = isBlocked.isTrue
  443. await store.save<StorageSystemParameters>(storageSystem)
  444. }
  445. export async function storage_DataObjectPerMegabyteFeeUpdated({
  446. event,
  447. store,
  448. }: EventContext & StoreContext): Promise<void> {
  449. const [newFee] = new Storage.DataObjectPerMegabyteFeeUpdatedEvent(event).params
  450. const storageSystem = await getStorageSystem(store)
  451. storageSystem.dataObjectFeePerMb = newFee
  452. await store.save<StorageSystemParameters>(storageSystem)
  453. }