BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet 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 
graphene::chain::worker_type
static_variant< refund_worker_type, vesting_balance_worker_type, burn_worker_type > worker_type
Definition: worker_object.hpp:101
graphene::chain::worker_object::approving_stake
share_type approving_stake() const
Definition: worker_object.hpp:137
graphene::chain::worker_object::work_begin_date
time_point_sec work_begin_date
Time at which this worker begins receiving pay, if elected.
Definition: worker_object.hpp:113
graphene::chain::database
tracks the blockchain state in an extensible manner
Definition: database.hpp:70
graphene::chain::refund_worker_type::pay_worker
void pay_worker(share_type pay, database &)
Definition: worker_evaluator.cpp:107
fc::static_variant
Definition: raw_fwd.hpp:27
FC_REFLECT_TYPENAME
FC_REFLECT_TYPENAME(fc::log_message)
graphene::chain::vesting_balance_worker_type::pay_worker
void pay_worker(share_type pay, database &db)
Definition: worker_evaluator.cpp:115
graphene::chain::worker_object_multi_index_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
Definition: worker_object.hpp:145
generic_index.hpp
MAP_OBJECT_ID_TO_TYPE
#define MAP_OBJECT_ID_TO_TYPE(OBJECT)
Definition: object_id.hpp:93
graphene::protocol::vote_id_type
An ID for some votable object.
Definition: vote.hpp:51
graphene::db::abstract_object
Definition: object.hpp:107
graphene::chain::refund_worker_type::total_burned
share_type total_burned
Record of how much this worker has burned in his lifetime.
Definition: worker_object.hpp:64
graphene::chain::burn_worker_type::pay_worker
void pay_worker(share_type pay, database &)
Definition: worker_evaluator.cpp:123
graphene::chain::vesting_balance_worker_type
A worker who sends his pay to a vesting balance.
Definition: worker_object.hpp:74
graphene::chain::worker_object::work_end_date
time_point_sec work_end_date
Time at which this worker will cease to receive pay. Worker will be deleted at this time.
Definition: worker_object.hpp:115
fc::time_point_sec
Definition: time.hpp:74
graphene::chain::worker_object::total_votes_for
uint64_t total_votes_for
Definition: worker_object.hpp:130
graphene::chain::worker_object::url
string url
URL to a web page representing this worker.
Definition: worker_object.hpp:123
GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION
#define GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION(type)
Definition: types.hpp:85
graphene::chain::worker_object::daily_pay
share_type daily_pay
Amount in CORE this worker will be paid each day.
Definition: worker_object.hpp:117
graphene::chain::vesting_balance_worker_type::balance
vesting_balance_id_type balance
The balance this worker pays into.
Definition: worker_object.hpp:77
graphene::chain::worker_object::worker
worker_type worker
ID of this worker's pay balance.
Definition: worker_object.hpp:119
vote.hpp
graphene::chain::worker_object::is_active
bool is_active(fc::time_point_sec now) const
Definition: worker_object.hpp:133
graphene::chain::worker_object
Worker object contains the details of a blockchain worker. See The Blockchain Worker System for detai...
Definition: worker_object.hpp:107
graphene::chain::worker_object::name
string name
Human-readable name for the worker.
Definition: worker_object.hpp:121
graphene::chain::burn_worker_type::total_burned
share_type total_burned
Record of how much this worker has burned in his lifetime.
Definition: worker_object.hpp:90
graphene::chain::worker_object::total_votes_against
uint64_t total_votes_against
Definition: worker_object.hpp:131
types.hpp
graphene::chain::refund_worker_type
A worker who returns all of his pay to the reserve.
Definition: worker_object.hpp:61
graphene::db::generic_index
Definition: generic_index.hpp:43
graphene::chain::burn_worker_type
A worker who permanently destroys all of his pay.
Definition: worker_object.hpp:87
graphene::chain::worker_object::worker_account
account_id_type worker_account
ID of the account which owns this worker.
Definition: worker_object.hpp:111
graphene::chain::worker_object::vote_for
vote_id_type vote_for
Voting ID which represents approval of this worker.
Definition: worker_object.hpp:126
graphene::chain::worker_object::vote_against
vote_id_type vote_against
Voting ID which represents disapproval of this worker.
Definition: worker_object.hpp:128
graphene
Definition: api.cpp:48
fc::safe
Definition: safe.hpp:26