-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Add reserved attribute #2868
Closed
Closed
Add reserved attribute #2868
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4400060
Reserved attribute
shargon 8af39eb
Fix ut
shargon ef66140
Fix ut
shargon 44decd5
Update TransactionAttributeType.cs
shargon 8f2fe0c
Update UT_HighPriorityAttribute.cs
shargon d0e587d
Update UT_NotValidBefore.cs
shargon 2c2109f
Update TransactionAttributeType.cs
shargon e3788e2
Merge branch 'master' into reserve-attr
Jim8y 329d7fa
Merge branch 'master' into reserve-attr
Jim8y f06cf76
Merge branch 'master' into reserve-attr
Jim8y File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (C) 2015-2023 The Neo Project. | ||
// | ||
// The neo is free software distributed under the MIT software license, | ||
// see the accompanying file LICENSE in the main directory of the | ||
// project or http://www.opensource.org/licenses/mit-license.php | ||
// for more details. | ||
// | ||
// Redistribution and use in source and binary forms with or without | ||
// modifications are permitted. | ||
|
||
using System; | ||
using System.IO; | ||
using Neo.IO; | ||
using Neo.Json; | ||
|
||
namespace Neo.Network.P2P.Payloads | ||
{ | ||
/// <summary> | ||
/// Reserved attribute for dApps. | ||
/// </summary> | ||
public class ReservedAttribute : TransactionAttribute | ||
{ | ||
private byte[] _reserved; | ||
|
||
public override bool AllowMultiple => true; | ||
public override TransactionAttributeType Type => TransactionAttributeType.ReservedAttribute; | ||
|
||
protected override void DeserializeWithoutType(ref MemoryReader reader) | ||
{ | ||
_reserved = reader.ReadVarMemory(ushort.MaxValue).ToArray(); | ||
} | ||
|
||
protected override void SerializeWithoutType(BinaryWriter writer) | ||
{ | ||
writer.WriteVarBytes(_reserved); | ||
} | ||
|
||
public override JObject ToJson() | ||
{ | ||
var json = base.ToJson(); | ||
json["value"] = Convert.ToBase64String(_reserved); | ||
return json; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Actually, the idea was to have a range of attributes (suppose you're creating an alternative to #1573 and defining 10 attributes instead of 3). And it's better be some upper range to reduce collisions with "regular" type.
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 in #1904 (comment)
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.
What do you mean by "Range of Attributes"?
In the way it is implemented we can setup a reserved byte that have
ff
possibilities as range for the dapp, right @shargon ?