Struct AppProtocolVersion
A claim of a version.
Every peer in network shows others their AppProtocolVersion information. As every peer can change its software by itself, this AppProtocolVersion is theoretically arbitrary, hence a “claim.” (i.e., no authority).
In order to verify who claimed a version, every AppProtocolVersion has its Signature which is made by its Signer. Verify(PublicKey) method purposes to determine whether an information is claimed by its corresponding Signer in fact.
Implements
Namespace: Libplanet.Net
Assembly: Libplanet.dll
Syntax
public struct AppProtocolVersion : IEquatable<AppProtocolVersion>
Constructors
| Improve this Doc View SourceAppProtocolVersion(Int32, IValue, ImmutableArray<Byte>, Address)
Initializes an AppProtocolVersion value with field values.
Declaration
public AppProtocolVersion(int version, IValue extra, ImmutableArray<byte> signature, Address signer)
Parameters
Type | Name | Description |
---|---|---|
Int32 | version | Sets the Version. |
IValue | extra | Sets the Extra. |
ImmutableArray<Byte> | signature | Sets the Signature. |
Address | signer | Gets the Signer. |
Fields
| Improve this Doc View SourceExtra
Optional extra data about the version. This can be used for any purpose by apps, such as a URL to download the software.
Declaration
public readonly IValue Extra
Field Value
Type | Description |
---|---|
IValue |
Signer
A signer who claims presence of a version.
Declaration
public readonly Address Signer
Field Value
Type | Description |
---|---|
Address |
Version
The version number. This does not have to be increased by only 1, but can be more than that.
Declaration
public readonly int Version
Field Value
Type | Description |
---|---|
Int32 |
Properties
| Improve this Doc View SourceSignature
A signature which verifies Signer's claim of a version.
Declaration
public ImmutableArray<byte> Signature { get; }
Property Value
Type | Description |
---|---|
ImmutableArray<Byte> |
Token
A token string which serializes an AppProtocolVersion.
As this is designed to be easy to copy and paste, the format consists of only printable characters in the ASCII character set.
A token can be deserialized into an AppProtocolVersion through FromToken(String) method.
Declaration
public string Token { get; }
Property Value
Type | Description |
---|---|
String |
See Also
Methods
| Improve this Doc View SourceEquals(AppProtocolVersion)
Declaration
public bool Equals(AppProtocolVersion other)
Parameters
Type | Name | Description |
---|---|---|
AppProtocolVersion | other |
Returns
Type | Description |
---|---|
Boolean |
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj |
Returns
Type | Description |
---|---|
Boolean |
FromToken(String)
Deserializes a Token into an AppProtocolVersion object.
Declaration
public static AppProtocolVersion FromToken(string token)
Parameters
Type | Name | Description |
---|---|---|
String | token | A Token string. |
Returns
Type | Description |
---|---|
AppProtocolVersion | A deserialized AppProtocolVersion object. |
See Also
| Improve this Doc View SourceGetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 |
Sign(PrivateKey, Int32, IValue)
Claim a version
with extra
data and sign it
using the given private key.
Declaration
public static AppProtocolVersion Sign(PrivateKey signer, int version, IValue extra = null)
Parameters
Type | Name | Description |
---|---|---|
PrivateKey | signer | A private key to sign the claim. |
Int32 | version | A version to claim. |
IValue | extra | Extra data to claim. |
Returns
Type | Description |
---|---|
AppProtocolVersion | A signed version claim. |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String |
Verify(PublicKey)
Verifies whether the claim is certainly signed by the Signer.
Declaration
public bool Verify(PublicKey publicKey)
Parameters
Type | Name | Description |
---|---|---|
PublicKey | publicKey | A public key of the Signer. |
Returns
Type | Description |
---|---|
Boolean |
|
Operators
| Improve this Doc View SourceEquality(AppProtocolVersion, AppProtocolVersion)
Declaration
public static bool operator ==(AppProtocolVersion left, AppProtocolVersion right)
Parameters
Type | Name | Description |
---|---|---|
AppProtocolVersion | left | |
AppProtocolVersion | right |
Returns
Type | Description |
---|---|
Boolean |
Inequality(AppProtocolVersion, AppProtocolVersion)
Declaration
public static bool operator !=(AppProtocolVersion left, AppProtocolVersion right)
Parameters
Type | Name | Description |
---|---|---|
AppProtocolVersion | left | |
AppProtocolVersion | right |
Returns
Type | Description |
---|---|
Boolean |