Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize plugin's models #3246

Merged
merged 3 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ namespace Neo.Plugins.Store.Models
{
public class ApplicationEngineLogModel
{
public UInt160 ScriptHash { get; private init; } = new();
public string Message { get; private init; } = string.Empty;
public required UInt160 ScriptHash { get; init; }
public required string Message { get; init; }

public static ApplicationEngineLogModel Create(EngineLogState logEventState) =>
new()
Expand Down
12 changes: 6 additions & 6 deletions src/Plugins/ApplicationLogs/Store/Models/BlockchainEventModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,27 @@ namespace ApplicationLogs.Store.Models
{
public class BlockchainEventModel
{
public UInt160 ScriptHash { get; private init; } = new();
public string EventName { get; private init; } = string.Empty;
public StackItem[] State { get; private init; } = [];
public required UInt160 ScriptHash { get; init; }
public required string EventName { get; init; }
public required StackItem[] State { get; init; }

public static BlockchainEventModel Create(UInt160 scriptHash, string eventName, StackItem[] state) =>
public static BlockchainEventModel Create(UInt160 scriptHash, string eventName, params StackItem[] state) =>
new()
{
ScriptHash = scriptHash,
EventName = eventName ?? string.Empty,
State = state,
};

public static BlockchainEventModel Create(NotifyLogState notifyLogState, StackItem[] state) =>
public static BlockchainEventModel Create(NotifyLogState notifyLogState, params StackItem[] state) =>
new()
{
ScriptHash = notifyLogState.ScriptHash,
EventName = notifyLogState.EventName,
State = state,
};

public static BlockchainEventModel Create(ContractLogState contractLogState, StackItem[] state) =>
public static BlockchainEventModel Create(ContractLogState contractLogState, params StackItem[] state) =>
new()
{
ScriptHash = contractLogState.ScriptHash,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,24 @@ namespace ApplicationLogs.Store.Models
{
public class BlockchainExecutionModel
{
public TriggerType Trigger { get; private init; } = TriggerType.All;
public VMState VmState { get; private init; } = VMState.NONE;
public string Exception { get; private init; } = string.Empty;
public long GasConsumed { get; private init; } = 0L;
public StackItem[] Stack { get; private init; } = [];
public BlockchainEventModel[] Notifications { get; set; } = [];
public ApplicationEngineLogModel[] Logs { get; set; } = [];
public required TriggerType Trigger { get; init; }
public required VMState VmState { get; init; }
public required string Exception { get; init; }
public required long GasConsumed { get; init; }
public required StackItem[] Stack { get; init; }
public required BlockchainEventModel[] Notifications { get; set; }
public required ApplicationEngineLogModel[] Logs { get; set; }

public static BlockchainExecutionModel Create(TriggerType trigger, ExecutionLogState executionLogState, StackItem[] stack) =>
public static BlockchainExecutionModel Create(TriggerType trigger, ExecutionLogState executionLogState, params StackItem[] stack) =>
new()
{
Trigger = trigger,
VmState = executionLogState.VmState,
Exception = executionLogState.Exception ?? string.Empty,
GasConsumed = executionLogState.GasConsumed,
Stack = stack,
Notifications = [],
Logs = []
};
}
}
Loading