BitShares-Core  6.1.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, protocol_ids, worker_object_type>
108 {
109  public:
111  account_id_type worker_account;
113  time_point_sec work_begin_date;
115  time_point_sec work_end_date;
121  string name;
123  string url;
124 
129 
130  uint64_t total_votes_for = 0;
131  uint64_t total_votes_against = 0;
132 
133  bool is_active(fc::time_point_sec now)const {
134  return now >= work_begin_date && now <= work_end_date;
135  }
136 
138  return int64_t( total_votes_for ) - int64_t( total_votes_against );
139  }
140 };
141 
142 struct by_account;
143 struct by_vote_for;
144 struct by_vote_against;
145 struct by_end_date;
146 typedef multi_index_container<
148  indexed_by<
149  ordered_unique< tag<by_id>, member< object, object_id_type, &object::id > >,
150  ordered_non_unique< tag<by_account>, member< worker_object, account_id_type, &worker_object::worker_account > >,
151  ordered_unique< tag<by_vote_for>, member< worker_object, vote_id_type, &worker_object::vote_for > >,
152  ordered_unique< tag<by_vote_against>, member< worker_object, vote_id_type, &worker_object::vote_against > >,
153  ordered_non_unique< tag<by_end_date>, member< worker_object, time_point_sec, &worker_object::work_end_date> >
154  >
156 
158 
159 } } // graphene::chain
160 
162 
168 
tracks the blockchain state in an extensible manner
Definition: database.hpp:70
Definition: api.cpp:48
#define MAP_OBJECT_ID_TO_TYPE(OBJECT)
Definition: object_id.hpp:93
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:85
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.
bool is_active(fc::time_point_sec now) const
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
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.
share_type approving_stake() const
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.