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 ebec467 commit de3178c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Neo/SmartContract/Native/RoleManagement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,18 @@ private void DesignateAsRole(ApplicationEngine engine, Role role, ECPoint[] node
list.AddRange(nodes);
list.Sort();
engine.SnapshotCache.Add(key, new StorageItem(list));
engine.SendNotification(Hash, "Designation", new VM.Types.Array(engine.ReferenceCounter, new StackItem[] { (int)role, engine.PersistingBlock.Index }));

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]));
}
}

private class NodeList : InteroperableList<ECPoint>
Expand Down

0 comments on commit de3178c

Please sign in to comment.