Esempio n. 1
0
 private static bool Storage_Find(ApplicationEngine engine)
 {
     if (engine.CurrentContext.EvaluationStack.Pop() is InteropInterface _interface)
     {
         StorageContext context = _interface.GetInterface <StorageContext>();
         if (!CheckStorageContext(engine, context))
         {
             return(false);
         }
         byte[] prefix = engine.CurrentContext.EvaluationStack.Pop().GetByteArray();
         byte[] prefix_key;
         using (MemoryStream ms = new MemoryStream())
         {
             int index  = 0;
             int remain = prefix.Length;
             while (remain >= 16)
             {
                 ms.Write(prefix, index, 16);
                 ms.WriteByte(0);
                 index  += 16;
                 remain -= 16;
             }
             if (remain > 0)
             {
                 ms.Write(prefix, index, remain);
             }
             prefix_key = context.ScriptHash.ToArray().Concat(ms.ToArray()).ToArray();
         }
         StorageIterator iterator = engine.AddDisposable(new StorageIterator(engine.Snapshot.Storages.Find(prefix_key).Where(p => p.Key.Key.Take(prefix.Length).SequenceEqual(prefix)).GetEnumerator()));
         engine.CurrentContext.EvaluationStack.Push(StackItem.FromInterface(iterator));
         return(true);
     }
     return(false);
 }