BitShares-Core  5.0.0
BitShares blockchain implementation and command-line interface software
worker_object.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Cryptonomex, Inc., and contributors.
3  *
4  * The MIT License
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 #pragma once
25 #include <graphene/chain/types.hpp>
28 
29 namespace graphene { namespace chain {
30 class database;
31 
62 {
65 
66  void pay_worker(share_type pay, database&);
67 };
68 
75 {
77  vesting_balance_id_type balance;
78 
79  void pay_worker(share_type pay, database& db);
80 };
81 
88 {
91 
92  void pay_worker(share_type pay, database&);
93 };
95 
96 // The ordering of types in these two static variants MUST be the same.
97 typedef static_variant<
102 
103 
107 class worker_object : public abstract_object<worker_object>
108 {
109  public:
110  static constexpr uint8_t space_id = protocol_ids;
111  static constexpr uint8_t type_id = worker_object_type;
112 
114  account_id_type worker_account;
116  time_point_sec work_begin_date;
118  time_point_sec work_end_date;
124  string name;
126  string url;
127 
132 
133  uint64_t total_votes_for = 0;
134  uint64_t total_votes_against = 0;
135 
136  bool is_active(fc::time_point_sec now)const {
137  return now >= work_begin_date && now <= work_end_date;
138  }
139 
141  return int64_t( total_votes_for ) - int64_t( total_votes_against );
142  }
143 };
144 
145 struct by_account;
146 struct by_vote_for;
147 struct by_vote_against;
148 struct by_end_date;
149 typedef multi_index_container<
151  indexed_by<
152  ordered_unique< tag<by_id>, member< object, object_id_type, &object::id > >,
153  ordered_non_unique< tag<by_account>, member< worker_object, account_id_type, &worker_object::worker_account > >,
154  ordered_unique< tag<by_vote_for>, member< worker_object, vote_id_type, &worker_object::vote_for > >,
155  ordered_unique< tag<by_vote_against>, member< worker_object, vote_id_type, &worker_object::vote_against > >,
156  ordered_non_unique< tag<by_end_date>, member< worker_object, time_point_sec, &worker_object::work_end_date> >
157  >
159 
161 
162 } } // graphene::chain
163 
165 
171 
share_type approving_stake() const
bool is_active(fc::time_point_sec now) const
tracks the blockchain state in an extensible manner
Definition: database.hpp:70
Definition: api.cpp:56
#define MAP_OBJECT_ID_TO_TYPE(OBJECT)
Definition: object_id.hpp:98
static_variant< refund_worker_type, vesting_balance_worker_type, burn_worker_type > worker_type
multi_index_container< worker_object, indexed_by< ordered_unique< tag< by_id >, member< object, object_id_type,&object::id > >, ordered_non_unique< tag< by_account >, member< worker_object, account_id_type,&worker_object::worker_account > >, ordered_unique< tag< by_vote_for >, member< worker_object, vote_id_type,&worker_object::vote_for > >, ordered_unique< tag< by_vote_against >, member< worker_object, vote_id_type,&worker_object::vote_against > >, ordered_non_unique< tag< by_end_date >, member< worker_object, time_point_sec,&worker_object::work_end_date > > >> worker_object_multi_index_type
FC_REFLECT_TYPENAME(fc::log_message)
share_type total_burned
Record of how much this worker has burned in his lifetime.
vesting_balance_id_type balance
The balance this worker pays into.
#define GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION(type)
Definition: types.hpp:73
string url
URL to a web page representing this worker.
void pay_worker(share_type pay, database &)
time_point_sec work_end_date
Time at which this worker will cease to receive pay. Worker will be deleted at this time...
worker_type worker
ID of this worker&#39;s pay balance.
share_type total_burned
Record of how much this worker has burned in his lifetime.
A worker who permanently destroys all of his pay.
A worker who returns all of his pay to the reserve.
An ID for some votable object.
Definition: vote.hpp:51
Use the Curiously Recurring Template Pattern to automatically add the ability to clone, serialize, and move objects polymorphically.
Definition: object.hpp:86
share_type daily_pay
Amount in CORE this worker will be paid each day.
vote_id_type vote_against
Voting ID which represents disapproval of this worker.
account_id_type worker_account
ID of the account which owns this worker.
Worker object contains the details of a blockchain worker. See The Blockchain Worker System for detai...
vote_id_type vote_for
Voting ID which represents approval of this worker.
time_point_sec work_begin_date
Time at which this worker begins receiving pay, if elected.
string name
Human-readable name for the worker.
A worker who sends his pay to a vesting balance.