Skip to content
Merged
Changes from all 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
18 changes: 17 additions & 1 deletion src/Neo/SmartContract/Native/NeoToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ public sealed class NeoToken : FungibleToken<NeoToken.NeoAccountState>
"from", ContractParameterType.PublicKey,
"to", ContractParameterType.PublicKey,
"amount", ContractParameterType.Integer)]
[ContractEvent(3, name: "CommitteeChanged",
"old", ContractParameterType.Array,
"new", ContractParameterType.Array)]
internal NeoToken() : base()
{
this.TotalAmount = 100000000 * Factor;
Expand Down Expand Up @@ -192,10 +195,23 @@ internal override ContractTask OnPersist(ApplicationEngine engine)
// Set next committee
if (ShouldRefreshCommittee(engine.PersistingBlock.Index, engine.ProtocolSettings.CommitteeMembersCount))
{
StorageItem storageItem = engine.Snapshot.GetAndChange(CreateStorageKey(Prefix_Committee));
var storageItem = engine.Snapshot.GetAndChange(CreateStorageKey(Prefix_Committee));
var cachedCommittee = storageItem.GetInteroperable<CachedCommittee>();

var prevCommittee = cachedCommittee.Select(u => u.PublicKey).ToArray();

cachedCommittee.Clear();
cachedCommittee.AddRange(ComputeCommitteeMembers(engine.Snapshot, engine.ProtocolSettings));

var newCommittee = cachedCommittee.Select(u => u.PublicKey).ToArray();

if (!newCommittee.SequenceEqual(prevCommittee))
{
engine.SendNotification(Hash, "CommitteeChanged", new VM.Types.Array(engine.ReferenceCounter) {
new VM.Types.Array(engine.ReferenceCounter, prevCommittee.Select(u => (ByteString)u.ToArray())) ,
new VM.Types.Array(engine.ReferenceCounter, newCommittee.Select(u => (ByteString)u.ToArray()))
});
}
}
return ContractTask.CompletedTask;
}
Expand Down