Skip to content

Commit

Permalink
Add entries to Designation event (#3397)
Browse files Browse the repository at this point in the history
* Add entries to Designation event

* Change to HF_Echidna

* Add UT

* Add count
  • Loading branch information
shargon authored and Jim8y committed Nov 17, 2024
1 parent ab313fc commit ebec467
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions src/Neo/SmartContract/Native/RoleManagement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,7 @@ private void DesignateAsRole(ApplicationEngine engine, Role role, ECPoint[] node
list.AddRange(nodes);
list.Sort();
engine.SnapshotCache.Add(key, new StorageItem(list));

if (engine.IsHardforkEnabled(Hardfork.HF_Echidna))
{
var oldNodes = new VM.Types.Array(engine.ReferenceCounter, GetDesignatedByRole(engine.Snapshot, role, index - 1).Select(u => (ByteString)u.EncodePoint(true)));
var newNodes = new VM.Types.Array(engine.ReferenceCounter, nodes.Select(u => (ByteString)u.EncodePoint(true)));

engine.SendNotification(Hash, "Designation", new VM.Types.Array(engine.ReferenceCounter, [(int)role, engine.PersistingBlock.Index, oldNodes, newNodes]));
}
else
{
engine.SendNotification(Hash, "Designation", new VM.Types.Array(engine.ReferenceCounter, [(int)role, engine.PersistingBlock.Index]));
}
engine.SendNotification(Hash, "Designation", new VM.Types.Array(engine.ReferenceCounter, new StackItem[] { (int)role, engine.PersistingBlock.Index }));
}

private class NodeList : InteroperableList<ECPoint>
Expand All @@ -99,7 +88,7 @@ protected override ECPoint ElementFromStackItem(StackItem item)
return ECPoint.DecodePoint(item.GetSpan(), ECCurve.Secp256r1);
}

protected override StackItem ElementToStackItem(ECPoint element, IReferenceCounter referenceCounter)
protected override StackItem ElementToStackItem(ECPoint element, ReferenceCounter referenceCounter)
{
return element.ToArray();
}
Expand Down

0 comments on commit ebec467

Please sign in to comment.