BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet software
Public Types | Public Member Functions | Public Attributes | Friends | List of all members
graphene::protocol::vote_id_type Struct Reference

An ID for some votable object. More...

#include <vote.hpp>

Public Types

enum  vote_type { committee, witness, worker, VOTE_TYPE_COUNT }
 

Public Member Functions

 vote_id_type ()=default
 
 vote_id_type (vote_type type, uint32_t instance=0)
 Construct this vote_id_type with provided type and instance. More...
 
 vote_id_type (const std::string &serial)
 Construct this vote_id_type from a serial string in the form "type:instance". More...
 
void set_type (vote_type type)
 Set the type of this vote_id_type. More...
 
vote_type type () const
 Get the type of this vote_id_type. More...
 
void set_instance (uint32_t instance)
 Set the instance of this vote_id_type. More...
 
uint32_t instance () const
 Get the instance of this vote_id_type. More...
 
vote_id_typeoperator= (vote_id_type other)
 
vote_id_typeoperator= (uint32_t instance)
 Set the instance of this vote_id_type. More...
 
 operator uint32_t () const
 Get the instance of this vote_id_type. More...
 
 operator std::string () const
 Convert this vote_id_type to a serial string in the form "type:instance". More...
 

Public Attributes

uint32_t content = 0
 

Friends

size_t hash_value (vote_id_type v)
 

Detailed Description

An ID for some votable object.

This class stores an ID for a votable object. The ID is comprised of two fields: a type, and an instance. The type field stores which kind of object is being voted on, and the instance stores which specific object of that type is being referenced by this ID.

A value of vote_id_type is implicitly convertible to an unsigned 32-bit integer containing only the instance. It may also be implicitly assigned from a uint32_t, which will update the instance. It may not, however, be implicitly constructed from a uint32_t, as in this case, the type would be unknown.

On the wire, a vote_id_type is represented as a 32-bit integer with the type in the lower 8 bits and the instance in the upper 24 bits. This means that types may never exceed 8 bits, and instances may never exceed 24 bits.

In JSON, a vote_id_type is represented as a string "type:instance", i.e. "1:5" would be type 1 and instance 5.

Note
In the BitShares protocol, vote_id_type instances are unique across types; that is to say, if an object of type 1 has instance 4, an object of type 0 may not also have instance 4. In other words, the type is not a namespace for instances; it is only an informational field.

Definition at line 51 of file vote.hpp.

Member Enumeration Documentation

◆ vote_type

Enumerator
committee 
witness 
worker 
VOTE_TYPE_COUNT 

Definition at line 58 of file vote.hpp.

Constructor & Destructor Documentation

◆ vote_id_type() [1/3]

graphene::protocol::vote_id_type::vote_id_type ( )
default

◆ vote_id_type() [2/3]

graphene::protocol::vote_id_type::vote_id_type ( vote_type  type,
uint32_t  instance = 0 
)
inlineexplicit

Construct this vote_id_type with provided type and instance.

Definition at line 68 of file vote.hpp.

◆ vote_id_type() [3/3]

graphene::protocol::vote_id_type::vote_id_type ( const std::string &  serial)
inlineexplicit

Construct this vote_id_type from a serial string in the form "type:instance".

Definition at line 72 of file vote.hpp.

Member Function Documentation

◆ instance()

uint32_t graphene::protocol::vote_id_type::instance ( ) const
inline

Get the instance of this vote_id_type.

Definition at line 100 of file vote.hpp.

◆ operator std::string()

graphene::protocol::vote_id_type::operator std::string ( ) const
inlineexplicit

Convert this vote_id_type to a serial string in the form "type:instance".

Definition at line 123 of file vote.hpp.

◆ operator uint32_t()

graphene::protocol::vote_id_type::operator uint32_t ( ) const
inline

Get the instance of this vote_id_type.

Definition at line 117 of file vote.hpp.

◆ operator=() [1/2]

vote_id_type& graphene::protocol::vote_id_type::operator= ( uint32_t  instance)
inline

Set the instance of this vote_id_type.

Definition at line 111 of file vote.hpp.

◆ operator=() [2/2]

vote_id_type& graphene::protocol::vote_id_type::operator= ( vote_id_type  other)
inline

Definition at line 105 of file vote.hpp.

◆ set_instance()

void graphene::protocol::vote_id_type::set_instance ( uint32_t  instance)
inline

Set the instance of this vote_id_type.

Definition at line 93 of file vote.hpp.

◆ set_type()

void graphene::protocol::vote_id_type::set_type ( vote_type  type)
inline

Set the type of this vote_id_type.

Definition at line 81 of file vote.hpp.

◆ type()

vote_type graphene::protocol::vote_id_type::type ( ) const
inline

Get the type of this vote_id_type.

Definition at line 87 of file vote.hpp.

Friends And Related Function Documentation

◆ hash_value

size_t hash_value ( vote_id_type  v)
friend

Definition at line 57 of file vote.hpp.

Member Data Documentation

◆ content

uint32_t graphene::protocol::vote_id_type::content = 0

Lower 8 bits are type; upper 24 bits are instance. By default type and instance are both set to 0.

Definition at line 55 of file vote.hpp.


The documentation for this struct was generated from the following file: