/// <summary> /// Bury an element of an array of entities in Storage based on a NeoStorageKey (NPC Level 4) /// </summary> /// <param name="vau">vau</param> /// <param name="index">index</param> /// <returns>NeoCounter</returns> public static NeoCounter BuryElement(NeoVersionedAppUser vau, byte[] domain, int index) { if (NeoVersionedAppUser.IsNull(vau)) // TODO - create NeoEntityModel.EntityState.BADKEY? { return(NeoCounter.Null()); } Neo.SmartContract.Framework.Services.Neo.StorageContext ctx = Neo.SmartContract.Framework.Services.Neo.Storage.CurrentContext; NeoStorageKey nsk = NeoStorageKey.New(vau, domain, _bClassName); //byte[] bkey; NeoCounter e; byte[] bsta = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, index, _bSTA)); if (NeoTrace.RUNTIME) { TraceRuntime("Bury(vau,index).NeoCounter.bsta", bsta.Length, bsta); } if (bsta.Length == 0) { e = NeoCounter.Missing(); } else // not MISSING - bury it { e = NeoCounter.Tombstone(); // TODO - should Bury() preserve the exist field values or re-initialize them? Preserve is cheaper but not as private Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, NeoStorageKey.StorageKey(nsk, index, _bSTA), e._state.AsBigInteger()); Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, NeoStorageKey.StorageKey(nsk, index, _bCurrentNumber), e._currentNumber); // NPCLevel4EBuryElement_cs.txt } // Template: NPCLevel4Part2_cs.txt if (NeoTrace.RUNTIME) { LogExt("Bury(vau,i).NeoCounter", e); } return(e); }