-
Notifications
You must be signed in to change notification settings - Fork 100
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
Avoid re-init properties #902
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,10 +18,10 @@ namespace ApplicationLogs.Store.States | |
{ | ||
public class ContractLogState : NotifyLogState, IEquatable<ContractLogState> | ||
{ | ||
public UInt256 TransactionHash { get; private set; } = new(); | ||
public TriggerType Trigger { get; private set; } = TriggerType.All; | ||
public UInt256 TransactionHash { get; private set; } | ||
public TriggerType Trigger { get; private set; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should make this |
||
|
||
public static ContractLogState Create(Blockchain.ApplicationExecuted applicationExecuted, NotifyEventArgs notifyEventArgs, Guid[] stackItemIds) => | ||
public static ContractLogState Create(Blockchain.ApplicationExecuted applicationExecuted, NotifyEventArgs notifyEventArgs, params Guid[] stackItemIds) => | ||
new() | ||
{ | ||
TransactionHash = applicationExecuted.Transaction?.Hash ?? new(), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,8 @@ namespace Neo.Plugins.Store.States | |
{ | ||
public class EngineLogState : ISerializable, IEquatable<EngineLogState> | ||
{ | ||
public UInt160 ScriptHash { get; private set; } = new(); | ||
public string Message { get; private set; } = string.Empty; | ||
public UInt160 ScriptHash { get; private set; } | ||
public string Message { get; private set; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should make this |
||
|
||
public static EngineLogState Create(UInt160 scriptHash, string message) => | ||
new() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,12 +17,12 @@ namespace ApplicationLogs.Store.States | |
{ | ||
public class ExecutionLogState : ISerializable, IEquatable<ExecutionLogState> | ||
{ | ||
public VMState VmState { get; private set; } = VMState.NONE; | ||
public string Exception { get; private set; } = string.Empty; | ||
public long GasConsumed { get; private set; } = 0L; | ||
public Guid[] StackItemIds { get; private set; } = []; | ||
public VMState VmState { get; private set; } | ||
public string Exception { get; private set; } | ||
public long GasConsumed { get; private set; } | ||
public Guid[] StackItemIds { get; private set; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should make this |
||
|
||
public static ExecutionLogState Create(Blockchain.ApplicationExecuted appExecution, Guid[] stackItemIds) => | ||
public static ExecutionLogState Create(Blockchain.ApplicationExecuted appExecution, params Guid[] stackItemIds) => | ||
new() | ||
{ | ||
VmState = appExecution.VMState, | ||
|
@@ -47,9 +47,9 @@ public void Deserialize(ref MemoryReader reader) | |
GasConsumed = reader.ReadInt64(); | ||
|
||
// It should be safe because it filled from a transaction's stack. | ||
uint aLen = reader.ReadUInt32(); | ||
var aLen = reader.ReadUInt32(); | ||
StackItemIds = new Guid[aLen]; | ||
for (int i = 0; i < aLen; i++) | ||
for (var i = 0; i < aLen; i++) | ||
StackItemIds[i] = new Guid(reader.ReadVarMemory().Span); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,11 +17,11 @@ namespace ApplicationLogs.Store.States | |
{ | ||
public class NotifyLogState : ISerializable, IEquatable<NotifyLogState> | ||
{ | ||
public UInt160 ScriptHash { get; protected set; } = new(); | ||
public string EventName { get; protected set; } = string.Empty; | ||
public Guid[] StackItemIds { get; protected set; } = []; | ||
public UInt160 ScriptHash { get; protected set; } | ||
public string EventName { get; protected set; } | ||
public Guid[] StackItemIds { get; protected set; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should make this |
||
|
||
public static NotifyLogState Create(NotifyEventArgs notifyItem, Guid[] stackItemsIds) => | ||
public static NotifyLogState Create(NotifyEventArgs notifyItem, params Guid[] stackItemsIds) => | ||
new() | ||
{ | ||
ScriptHash = notifyItem.ScriptHash, | ||
|
@@ -42,7 +42,7 @@ public virtual void Deserialize(ref MemoryReader reader) | |
EventName = reader.ReadVarString(); | ||
|
||
// It should be safe because it filled from a transaction's notifications. | ||
uint aLen = reader.ReadUInt32(); | ||
var aLen = reader.ReadUInt32(); | ||
StackItemIds = new Guid[aLen]; | ||
for (var i = 0; i < aLen; i++) | ||
StackItemIds[i] = new Guid(reader.ReadVarMemory().Span); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,9 +15,9 @@ namespace Neo.Plugins.Store.States | |
{ | ||
public class TransactionEngineLogState : ISerializable, IEquatable<TransactionEngineLogState> | ||
{ | ||
public Guid[] LogIds { get; private set; } = Array.Empty<Guid>(); | ||
public Guid[] LogIds { get; private set; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should make this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then set can't be private There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They have |
||
|
||
public static TransactionEngineLogState Create(Guid[] logIds) => | ||
public static TransactionEngineLogState Create(params Guid[] logIds) => | ||
new() | ||
{ | ||
LogIds = logIds, | ||
|
@@ -32,16 +32,16 @@ public static TransactionEngineLogState Create(Guid[] logIds) => | |
public virtual void Deserialize(ref MemoryReader reader) | ||
{ | ||
// It should be safe because it filled from a transaction's logs. | ||
uint aLen = reader.ReadUInt32(); | ||
var aLen = reader.ReadUInt32(); | ||
LogIds = new Guid[aLen]; | ||
for (int i = 0; i < aLen; i++) | ||
for (var i = 0; i < aLen; i++) | ||
LogIds[i] = new Guid(reader.ReadVarMemory().Span); | ||
} | ||
|
||
public virtual void Serialize(BinaryWriter writer) | ||
{ | ||
writer.Write((uint)LogIds.Length); | ||
for (int i = 0; i < LogIds.Length; i++) | ||
for (var i = 0; i < LogIds.Length; i++) | ||
writer.WriteVarBytes(LogIds[i].ToByteArray()); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,9 +16,9 @@ namespace ApplicationLogs.Store.States | |
{ | ||
public class TransactionLogState : ISerializable, IEquatable<TransactionLogState> | ||
{ | ||
public Guid[] NotifyLogIds { get; private set; } = Array.Empty<Guid>(); | ||
public Guid[] NotifyLogIds { get; private set; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should make this |
||
|
||
public static TransactionLogState Create(Guid[] notifyLogIds) => | ||
public static TransactionLogState Create(params Guid[] notifyLogIds) => | ||
new() | ||
{ | ||
NotifyLogIds = notifyLogIds, | ||
|
@@ -33,16 +33,16 @@ public static TransactionLogState Create(Guid[] notifyLogIds) => | |
public virtual void Deserialize(ref MemoryReader reader) | ||
{ | ||
// It should be safe because it filled from a transaction's notifications. | ||
uint aLen = reader.ReadUInt32(); | ||
var aLen = reader.ReadUInt32(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this related? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, it's just using dynamic type variable now; instead of being bound to a type specific variable. |
||
NotifyLogIds = new Guid[aLen]; | ||
for (int i = 0; i < aLen; i++) | ||
for (var i = 0; i < aLen; i++) | ||
NotifyLogIds[i] = new Guid(reader.ReadVarMemory().Span); | ||
} | ||
|
||
public virtual void Serialize(BinaryWriter writer) | ||
{ | ||
writer.Write((uint)NotifyLogIds.Length); | ||
for (int i = 0; i < NotifyLogIds.Length; i++) | ||
for (var i = 0; i < NotifyLogIds.Length; i++) | ||
writer.WriteVarBytes(NotifyLogIds[i].ToByteArray()); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should make this
required
as well.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
like this? Kinda ugly: