private bool CheckStorageContext(StorageContext context) { ContractState contract = contracts.TryGet(context.ScriptHash); if (contract == null) { return(false); } if (!contract.HasStorage) { return(false); } return(true); }
protected override bool Blockchain_GetAsset(ExecutionEngine engine) { UInt256 hash = new UInt256(engine.EvaluationStack.Pop().GetByteArray()); AssetState asset = assets.TryGet(hash); if (asset == null) { return(false); } engine.EvaluationStack.Push(StackItem.FromInterface(asset)); return(true); }
protected override bool Storage_Get(ExecutionEngine engine) { StorageContext context = engine.EvaluationStack.Pop().GetInterface <StorageContext>(); if (!CheckStorageContext(context)) { return(false); } byte[] key = engine.EvaluationStack.Pop().GetByteArray(); StorageItem item = storages.TryGet(new StorageKey { ScriptHash = context.ScriptHash, Key = key }); engine.EvaluationStack.Push(item?.Value ?? new byte[0]); return(true); }