コード例 #1
0
        protected bool Storage_Get(ExecutionEngine engine)
        {
            CustomStorageContext context = engine.EvaluationStack.Pop().GetInterface <CustomStorageContext>();

            byte[]      key  = engine.EvaluationStack.Pop().GetByteArray();
            StorageItem item = new StorageItem
            {
                Value = (byte[])context.data[Encoding.UTF8.GetString(key)]
            };

            engine.EvaluationStack.Push(item?.Value ?? new byte[0]);
            return(true);
        }
コード例 #2
0
        protected bool Storage_Put(ExecutionEngine engine)
        {
            CustomStorageContext context = engine.EvaluationStack.Pop().GetInterface <CustomStorageContext>();

            byte[] key = engine.EvaluationStack.Pop().GetByteArray();
            if (key.Length > 1024)
            {
                return(false);
            }
            byte[] value = engine.EvaluationStack.Pop().GetByteArray();
            context.data[Encoding.UTF8.GetString(key)] = value;
            return(true);
        }
コード例 #3
0
 public StateReader(ITestOutputHelper output)
 {
     this.output         = output;
     this.storageContext = new CustomStorageContext();
     Register("Neo.Blockchain.GetHeader", Blockchain_GetHeader);
     Register("Neo.Header.GetTimestamp", Header_GetTimestamp);
     Register("Neo.Runtime.CheckWitness", Runtime_CheckWitness);
     Register("Neo.Runtime.Notify", Runtime_Notify);
     Register("Neo.Runtime.Log", Runtime_Notify);
     Register("Neo.Storage.GetContext", Storage_GetContext);
     Register("Neo.Storage.Get", Storage_Get);
     Register("Neo.Storage.Put", Storage_Put);
 }