2019-03-05 16:05:34 -05:00
|
|
|
// Copyright (c) 2014-2019, The Monero Project
|
2014-07-23 09:03:52 -04:00
|
|
|
//
|
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without modification, are
|
|
|
|
// permitted provided that the following conditions are met:
|
|
|
|
//
|
|
|
|
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
|
|
|
// conditions and the following disclaimer.
|
|
|
|
//
|
|
|
|
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
|
|
// of conditions and the following disclaimer in the documentation and/or other
|
|
|
|
// materials provided with the distribution.
|
|
|
|
//
|
|
|
|
// 3. Neither the name of the copyright holder nor the names of its contributors may be
|
|
|
|
// used to endorse or promote products derived from this software without specific
|
|
|
|
// prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
|
|
|
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
|
|
|
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
|
|
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
|
|
|
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
//
|
|
|
|
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
|
2014-03-03 17:07:58 -05:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <boost/uuid/uuid.hpp>
|
Pruning
The blockchain prunes seven eighths of prunable tx data.
This saves about two thirds of the blockchain size, while
keeping the node useful as a sync source for an eighth
of the blockchain.
No other data is currently pruned.
There are three ways to prune a blockchain:
- run monerod with --prune-blockchain
- run "prune_blockchain" in the monerod console
- run the monero-blockchain-prune utility
The first two will prune in place. Due to how LMDB works, this
will not reduce the blockchain size on disk. Instead, it will
mark parts of the file as free, so that future data will use
that free space, causing the file to not grow until free space
grows scarce.
The third way will create a second database, a pruned copy of
the original one. Since this is a new file, this one will be
smaller than the original one.
Once the database is pruned, it will stay pruned as it syncs.
That is, there is no need to use --prune-blockchain again, etc.
2018-04-29 18:30:51 -04:00
|
|
|
#include <boost/serialization/version.hpp>
|
2014-03-03 17:07:58 -05:00
|
|
|
#include "serialization/keyvalue_serialization.h"
|
2017-05-27 06:35:54 -04:00
|
|
|
#include "net/net_utils_base.h"
|
2018-12-16 12:57:44 -05:00
|
|
|
#include "net/tor_address.h" // needed for serialization
|
2019-01-21 11:50:03 -05:00
|
|
|
#include "net/i2p_address.h" // needed for serialization
|
2014-03-03 17:07:58 -05:00
|
|
|
#include "misc_language.h"
|
2017-11-25 17:25:05 -05:00
|
|
|
#include "string_tools.h"
|
|
|
|
#include "time_helper.h"
|
2014-03-03 17:07:58 -05:00
|
|
|
#include "cryptonote_config.h"
|
2017-07-31 11:36:52 -04:00
|
|
|
#ifdef ALLOW_DEBUG_COMMANDS
|
2014-03-03 17:07:58 -05:00
|
|
|
#include "crypto/crypto.h"
|
2017-07-31 11:36:52 -04:00
|
|
|
#endif
|
2014-03-03 17:07:58 -05:00
|
|
|
|
|
|
|
namespace nodetool
|
|
|
|
{
|
|
|
|
typedef boost::uuids::uuid uuid;
|
|
|
|
typedef uint64_t peerid_type;
|
|
|
|
|
2017-08-20 16:15:53 -04:00
|
|
|
static inline std::string peerid_to_string(peerid_type peer_id)
|
|
|
|
{
|
|
|
|
std::ostringstream s;
|
|
|
|
s << std::hex << peer_id;
|
|
|
|
return epee::string_tools::pad_string(s.str(), 16, '0', true);
|
|
|
|
}
|
|
|
|
|
2014-03-03 17:07:58 -05:00
|
|
|
#pragma pack (push, 1)
|
|
|
|
|
2017-05-27 06:35:54 -04:00
|
|
|
struct network_address_old
|
2014-03-03 17:07:58 -05:00
|
|
|
{
|
2014-03-20 07:46:11 -04:00
|
|
|
uint32_t ip;
|
|
|
|
uint32_t port;
|
2017-05-27 06:35:54 -04:00
|
|
|
|
|
|
|
BEGIN_KV_SERIALIZE_MAP()
|
|
|
|
KV_SERIALIZE(ip)
|
|
|
|
KV_SERIALIZE(port)
|
|
|
|
END_KV_SERIALIZE_MAP()
|
2014-03-03 17:07:58 -05:00
|
|
|
};
|
|
|
|
|
2017-05-27 06:35:54 -04:00
|
|
|
template<typename AddressType>
|
|
|
|
struct peerlist_entry_base
|
2014-03-03 17:07:58 -05:00
|
|
|
{
|
2017-05-27 06:35:54 -04:00
|
|
|
AddressType adr;
|
2014-03-03 17:07:58 -05:00
|
|
|
peerid_type id;
|
2014-08-20 11:57:29 -04:00
|
|
|
int64_t last_seen;
|
Pruning
The blockchain prunes seven eighths of prunable tx data.
This saves about two thirds of the blockchain size, while
keeping the node useful as a sync source for an eighth
of the blockchain.
No other data is currently pruned.
There are three ways to prune a blockchain:
- run monerod with --prune-blockchain
- run "prune_blockchain" in the monerod console
- run the monero-blockchain-prune utility
The first two will prune in place. Due to how LMDB works, this
will not reduce the blockchain size on disk. Instead, it will
mark parts of the file as free, so that future data will use
that free space, causing the file to not grow until free space
grows scarce.
The third way will create a second database, a pruned copy of
the original one. Since this is a new file, this one will be
smaller than the original one.
Once the database is pruned, it will stay pruned as it syncs.
That is, there is no need to use --prune-blockchain again, etc.
2018-04-29 18:30:51 -04:00
|
|
|
uint32_t pruning_seed;
|
2019-02-24 03:47:49 -05:00
|
|
|
uint16_t rpc_port;
|
daemon, wallet: new pay for RPC use system
Daemons intended for public use can be set up to require payment
in the form of hashes in exchange for RPC service. This enables
public daemons to receive payment for their work over a large
number of calls. This system behaves similarly to a pool, so
payment takes the form of valid blocks every so often, yielding
a large one off payment, rather than constant micropayments.
This system can also be used by third parties as a "paywall"
layer, where users of a service can pay for use by mining Monero
to the service provider's address. An example of this for web
site access is Primo, a Monero mining based website "paywall":
https://github.com/selene-kovri/primo
This has some advantages:
- incentive to run a node providing RPC services, thereby promoting the availability of third party nodes for those who can't run their own
- incentive to run your own node instead of using a third party's, thereby promoting decentralization
- decentralized: payment is done between a client and server, with no third party needed
- private: since the system is "pay as you go", you don't need to identify yourself to claim a long lived balance
- no payment occurs on the blockchain, so there is no extra transactional load
- one may mine with a beefy server, and use those credits from a phone, by reusing the client ID (at the cost of some privacy)
- no barrier to entry: anyone may run a RPC node, and your expected revenue depends on how much work you do
- Sybil resistant: if you run 1000 idle RPC nodes, you don't magically get more revenue
- no large credit balance maintained on servers, so they have no incentive to exit scam
- you can use any/many node(s), since there's little cost in switching servers
- market based prices: competition between servers to lower costs
- incentive for a distributed third party node system: if some public nodes are overused/slow, traffic can move to others
- increases network security
- helps counteract mining pools' share of the network hash rate
- zero incentive for a payer to "double spend" since a reorg does not give any money back to the miner
And some disadvantages:
- low power clients will have difficulty mining (but one can optionally mine in advance and/or with a faster machine)
- payment is "random", so a server might go a long time without a block before getting one
- a public node's overall expected payment may be small
Public nodes are expected to compete to find a suitable level for
cost of service.
The daemon can be set up this way to require payment for RPC services:
monerod --rpc-payment-address 4xxxxxx \
--rpc-payment-credits 250 --rpc-payment-difficulty 1000
These values are an example only.
The --rpc-payment-difficulty switch selects how hard each "share" should
be, similar to a mining pool. The higher the difficulty, the fewer
shares a client will find.
The --rpc-payment-credits switch selects how many credits are awarded
for each share a client finds.
Considering both options, clients will be awarded credits/difficulty
credits for every hash they calculate. For example, in the command line
above, 0.25 credits per hash. A client mining at 100 H/s will therefore
get an average of 25 credits per second.
For reference, in the current implementation, a credit is enough to
sync 20 blocks, so a 100 H/s client that's just starting to use Monero
and uses this daemon will be able to sync 500 blocks per second.
The wallet can be set to automatically mine if connected to a daemon
which requires payment for RPC usage. It will try to keep a balance
of 50000 credits, stopping mining when it's at this level, and starting
again as credits are spent. With the example above, a new client will
mine this much credits in about half an hour, and this target is enough
to sync 500000 blocks (currently about a third of the monero blockchain).
There are three new settings in the wallet:
- credits-target: this is the amount of credits a wallet will try to
reach before stopping mining. The default of 0 means 50000 credits.
- auto-mine-for-rpc-payment-threshold: this controls the minimum
credit rate which the wallet considers worth mining for. If the
daemon credits less than this ratio, the wallet will consider mining
to be not worth it. In the example above, the rate is 0.25
- persistent-rpc-client-id: if set, this allows the wallet to reuse
a client id across runs. This means a public node can tell a wallet
that's connecting is the same as one that connected previously, but
allows a wallet to keep their credit balance from one run to the
other. Since the wallet only mines to keep a small credit balance,
this is not normally worth doing. However, someone may want to mine
on a fast server, and use that credit balance on a low power device
such as a phone. If left unset, a new client ID is generated at
each wallet start, for privacy reasons.
To mine and use a credit balance on two different devices, you can
use the --rpc-client-secret-key switch. A wallet's client secret key
can be found using the new rpc_payments command in the wallet.
Note: anyone knowing your RPC client secret key is able to use your
credit balance.
The wallet has a few new commands too:
- start_mining_for_rpc: start mining to acquire more credits,
regardless of the auto mining settings
- stop_mining_for_rpc: stop mining to acquire more credits
- rpc_payments: display information about current credits with
the currently selected daemon
The node has an extra command:
- rpc_payments: display information about clients and their
balances
The node will forget about any balance for clients which have
been inactive for 6 months. Balances carry over on node restart.
2018-02-11 10:15:56 -05:00
|
|
|
uint32_t rpc_credits_per_hash;
|
2017-05-27 06:35:54 -04:00
|
|
|
|
|
|
|
BEGIN_KV_SERIALIZE_MAP()
|
|
|
|
KV_SERIALIZE(adr)
|
|
|
|
KV_SERIALIZE(id)
|
2019-04-23 07:07:44 -04:00
|
|
|
if (!is_store || this_ref.last_seen != 0)
|
|
|
|
KV_SERIALIZE_OPT(last_seen, (int64_t)0)
|
Pruning
The blockchain prunes seven eighths of prunable tx data.
This saves about two thirds of the blockchain size, while
keeping the node useful as a sync source for an eighth
of the blockchain.
No other data is currently pruned.
There are three ways to prune a blockchain:
- run monerod with --prune-blockchain
- run "prune_blockchain" in the monerod console
- run the monero-blockchain-prune utility
The first two will prune in place. Due to how LMDB works, this
will not reduce the blockchain size on disk. Instead, it will
mark parts of the file as free, so that future data will use
that free space, causing the file to not grow until free space
grows scarce.
The third way will create a second database, a pruned copy of
the original one. Since this is a new file, this one will be
smaller than the original one.
Once the database is pruned, it will stay pruned as it syncs.
That is, there is no need to use --prune-blockchain again, etc.
2018-04-29 18:30:51 -04:00
|
|
|
KV_SERIALIZE_OPT(pruning_seed, (uint32_t)0)
|
2019-02-24 03:47:49 -05:00
|
|
|
KV_SERIALIZE_OPT(rpc_port, (uint16_t)0)
|
daemon, wallet: new pay for RPC use system
Daemons intended for public use can be set up to require payment
in the form of hashes in exchange for RPC service. This enables
public daemons to receive payment for their work over a large
number of calls. This system behaves similarly to a pool, so
payment takes the form of valid blocks every so often, yielding
a large one off payment, rather than constant micropayments.
This system can also be used by third parties as a "paywall"
layer, where users of a service can pay for use by mining Monero
to the service provider's address. An example of this for web
site access is Primo, a Monero mining based website "paywall":
https://github.com/selene-kovri/primo
This has some advantages:
- incentive to run a node providing RPC services, thereby promoting the availability of third party nodes for those who can't run their own
- incentive to run your own node instead of using a third party's, thereby promoting decentralization
- decentralized: payment is done between a client and server, with no third party needed
- private: since the system is "pay as you go", you don't need to identify yourself to claim a long lived balance
- no payment occurs on the blockchain, so there is no extra transactional load
- one may mine with a beefy server, and use those credits from a phone, by reusing the client ID (at the cost of some privacy)
- no barrier to entry: anyone may run a RPC node, and your expected revenue depends on how much work you do
- Sybil resistant: if you run 1000 idle RPC nodes, you don't magically get more revenue
- no large credit balance maintained on servers, so they have no incentive to exit scam
- you can use any/many node(s), since there's little cost in switching servers
- market based prices: competition between servers to lower costs
- incentive for a distributed third party node system: if some public nodes are overused/slow, traffic can move to others
- increases network security
- helps counteract mining pools' share of the network hash rate
- zero incentive for a payer to "double spend" since a reorg does not give any money back to the miner
And some disadvantages:
- low power clients will have difficulty mining (but one can optionally mine in advance and/or with a faster machine)
- payment is "random", so a server might go a long time without a block before getting one
- a public node's overall expected payment may be small
Public nodes are expected to compete to find a suitable level for
cost of service.
The daemon can be set up this way to require payment for RPC services:
monerod --rpc-payment-address 4xxxxxx \
--rpc-payment-credits 250 --rpc-payment-difficulty 1000
These values are an example only.
The --rpc-payment-difficulty switch selects how hard each "share" should
be, similar to a mining pool. The higher the difficulty, the fewer
shares a client will find.
The --rpc-payment-credits switch selects how many credits are awarded
for each share a client finds.
Considering both options, clients will be awarded credits/difficulty
credits for every hash they calculate. For example, in the command line
above, 0.25 credits per hash. A client mining at 100 H/s will therefore
get an average of 25 credits per second.
For reference, in the current implementation, a credit is enough to
sync 20 blocks, so a 100 H/s client that's just starting to use Monero
and uses this daemon will be able to sync 500 blocks per second.
The wallet can be set to automatically mine if connected to a daemon
which requires payment for RPC usage. It will try to keep a balance
of 50000 credits, stopping mining when it's at this level, and starting
again as credits are spent. With the example above, a new client will
mine this much credits in about half an hour, and this target is enough
to sync 500000 blocks (currently about a third of the monero blockchain).
There are three new settings in the wallet:
- credits-target: this is the amount of credits a wallet will try to
reach before stopping mining. The default of 0 means 50000 credits.
- auto-mine-for-rpc-payment-threshold: this controls the minimum
credit rate which the wallet considers worth mining for. If the
daemon credits less than this ratio, the wallet will consider mining
to be not worth it. In the example above, the rate is 0.25
- persistent-rpc-client-id: if set, this allows the wallet to reuse
a client id across runs. This means a public node can tell a wallet
that's connecting is the same as one that connected previously, but
allows a wallet to keep their credit balance from one run to the
other. Since the wallet only mines to keep a small credit balance,
this is not normally worth doing. However, someone may want to mine
on a fast server, and use that credit balance on a low power device
such as a phone. If left unset, a new client ID is generated at
each wallet start, for privacy reasons.
To mine and use a credit balance on two different devices, you can
use the --rpc-client-secret-key switch. A wallet's client secret key
can be found using the new rpc_payments command in the wallet.
Note: anyone knowing your RPC client secret key is able to use your
credit balance.
The wallet has a few new commands too:
- start_mining_for_rpc: start mining to acquire more credits,
regardless of the auto mining settings
- stop_mining_for_rpc: stop mining to acquire more credits
- rpc_payments: display information about current credits with
the currently selected daemon
The node has an extra command:
- rpc_payments: display information about clients and their
balances
The node will forget about any balance for clients which have
been inactive for 6 months. Balances carry over on node restart.
2018-02-11 10:15:56 -05:00
|
|
|
KV_SERIALIZE_OPT(rpc_credits_per_hash, (uint32_t)0)
|
2017-05-27 06:35:54 -04:00
|
|
|
END_KV_SERIALIZE_MAP()
|
2014-03-03 17:07:58 -05:00
|
|
|
};
|
2017-05-27 06:35:54 -04:00
|
|
|
typedef peerlist_entry_base<epee::net_utils::network_address> peerlist_entry;
|
2014-03-03 17:07:58 -05:00
|
|
|
|
2017-05-27 06:35:54 -04:00
|
|
|
template<typename AddressType>
|
|
|
|
struct anchor_peerlist_entry_base
|
2017-02-08 19:11:58 -05:00
|
|
|
{
|
2017-05-27 06:35:54 -04:00
|
|
|
AddressType adr;
|
2017-02-08 19:11:58 -05:00
|
|
|
peerid_type id;
|
|
|
|
int64_t first_seen;
|
2017-05-27 06:35:54 -04:00
|
|
|
|
|
|
|
BEGIN_KV_SERIALIZE_MAP()
|
|
|
|
KV_SERIALIZE(adr)
|
|
|
|
KV_SERIALIZE(id)
|
|
|
|
KV_SERIALIZE(first_seen)
|
|
|
|
END_KV_SERIALIZE_MAP()
|
2017-02-08 19:11:58 -05:00
|
|
|
};
|
2017-05-27 06:35:54 -04:00
|
|
|
typedef anchor_peerlist_entry_base<epee::net_utils::network_address> anchor_peerlist_entry;
|
2017-02-08 19:11:58 -05:00
|
|
|
|
2017-05-27 06:35:54 -04:00
|
|
|
template<typename AddressType>
|
|
|
|
struct connection_entry_base
|
2014-03-03 17:07:58 -05:00
|
|
|
{
|
2017-05-27 06:35:54 -04:00
|
|
|
AddressType adr;
|
2014-03-03 17:07:58 -05:00
|
|
|
peerid_type id;
|
|
|
|
bool is_income;
|
2017-05-27 06:35:54 -04:00
|
|
|
|
|
|
|
BEGIN_KV_SERIALIZE_MAP()
|
|
|
|
KV_SERIALIZE(adr)
|
|
|
|
KV_SERIALIZE(id)
|
|
|
|
KV_SERIALIZE(is_income)
|
|
|
|
END_KV_SERIALIZE_MAP()
|
2014-03-03 17:07:58 -05:00
|
|
|
};
|
2017-05-27 06:35:54 -04:00
|
|
|
typedef connection_entry_base<epee::net_utils::network_address> connection_entry;
|
2014-03-03 17:07:58 -05:00
|
|
|
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
inline
|
2018-12-05 17:25:27 -05:00
|
|
|
std::string print_peerlist_to_string(const std::vector<peerlist_entry>& pl)
|
2014-03-03 17:07:58 -05:00
|
|
|
{
|
|
|
|
time_t now_time = 0;
|
|
|
|
time(&now_time);
|
|
|
|
std::stringstream ss;
|
|
|
|
ss << std::setfill ('0') << std::setw (8) << std::hex << std::noshowbase;
|
2017-01-22 15:38:10 -05:00
|
|
|
for(const peerlist_entry& pe: pl)
|
2014-03-03 17:07:58 -05:00
|
|
|
{
|
2019-02-24 03:47:49 -05:00
|
|
|
ss << pe.id << "\t" << pe.adr.str()
|
|
|
|
<< " \trpc port " << (pe.rpc_port > 0 ? std::to_string(pe.rpc_port) : "-")
|
daemon, wallet: new pay for RPC use system
Daemons intended for public use can be set up to require payment
in the form of hashes in exchange for RPC service. This enables
public daemons to receive payment for their work over a large
number of calls. This system behaves similarly to a pool, so
payment takes the form of valid blocks every so often, yielding
a large one off payment, rather than constant micropayments.
This system can also be used by third parties as a "paywall"
layer, where users of a service can pay for use by mining Monero
to the service provider's address. An example of this for web
site access is Primo, a Monero mining based website "paywall":
https://github.com/selene-kovri/primo
This has some advantages:
- incentive to run a node providing RPC services, thereby promoting the availability of third party nodes for those who can't run their own
- incentive to run your own node instead of using a third party's, thereby promoting decentralization
- decentralized: payment is done between a client and server, with no third party needed
- private: since the system is "pay as you go", you don't need to identify yourself to claim a long lived balance
- no payment occurs on the blockchain, so there is no extra transactional load
- one may mine with a beefy server, and use those credits from a phone, by reusing the client ID (at the cost of some privacy)
- no barrier to entry: anyone may run a RPC node, and your expected revenue depends on how much work you do
- Sybil resistant: if you run 1000 idle RPC nodes, you don't magically get more revenue
- no large credit balance maintained on servers, so they have no incentive to exit scam
- you can use any/many node(s), since there's little cost in switching servers
- market based prices: competition between servers to lower costs
- incentive for a distributed third party node system: if some public nodes are overused/slow, traffic can move to others
- increases network security
- helps counteract mining pools' share of the network hash rate
- zero incentive for a payer to "double spend" since a reorg does not give any money back to the miner
And some disadvantages:
- low power clients will have difficulty mining (but one can optionally mine in advance and/or with a faster machine)
- payment is "random", so a server might go a long time without a block before getting one
- a public node's overall expected payment may be small
Public nodes are expected to compete to find a suitable level for
cost of service.
The daemon can be set up this way to require payment for RPC services:
monerod --rpc-payment-address 4xxxxxx \
--rpc-payment-credits 250 --rpc-payment-difficulty 1000
These values are an example only.
The --rpc-payment-difficulty switch selects how hard each "share" should
be, similar to a mining pool. The higher the difficulty, the fewer
shares a client will find.
The --rpc-payment-credits switch selects how many credits are awarded
for each share a client finds.
Considering both options, clients will be awarded credits/difficulty
credits for every hash they calculate. For example, in the command line
above, 0.25 credits per hash. A client mining at 100 H/s will therefore
get an average of 25 credits per second.
For reference, in the current implementation, a credit is enough to
sync 20 blocks, so a 100 H/s client that's just starting to use Monero
and uses this daemon will be able to sync 500 blocks per second.
The wallet can be set to automatically mine if connected to a daemon
which requires payment for RPC usage. It will try to keep a balance
of 50000 credits, stopping mining when it's at this level, and starting
again as credits are spent. With the example above, a new client will
mine this much credits in about half an hour, and this target is enough
to sync 500000 blocks (currently about a third of the monero blockchain).
There are three new settings in the wallet:
- credits-target: this is the amount of credits a wallet will try to
reach before stopping mining. The default of 0 means 50000 credits.
- auto-mine-for-rpc-payment-threshold: this controls the minimum
credit rate which the wallet considers worth mining for. If the
daemon credits less than this ratio, the wallet will consider mining
to be not worth it. In the example above, the rate is 0.25
- persistent-rpc-client-id: if set, this allows the wallet to reuse
a client id across runs. This means a public node can tell a wallet
that's connecting is the same as one that connected previously, but
allows a wallet to keep their credit balance from one run to the
other. Since the wallet only mines to keep a small credit balance,
this is not normally worth doing. However, someone may want to mine
on a fast server, and use that credit balance on a low power device
such as a phone. If left unset, a new client ID is generated at
each wallet start, for privacy reasons.
To mine and use a credit balance on two different devices, you can
use the --rpc-client-secret-key switch. A wallet's client secret key
can be found using the new rpc_payments command in the wallet.
Note: anyone knowing your RPC client secret key is able to use your
credit balance.
The wallet has a few new commands too:
- start_mining_for_rpc: start mining to acquire more credits,
regardless of the auto mining settings
- stop_mining_for_rpc: stop mining to acquire more credits
- rpc_payments: display information about current credits with
the currently selected daemon
The node has an extra command:
- rpc_payments: display information about clients and their
balances
The node will forget about any balance for clients which have
been inactive for 6 months. Balances carry over on node restart.
2018-02-11 10:15:56 -05:00
|
|
|
<< " \trpc credits per hash " << (pe.rpc_credits_per_hash > 0 ? std::to_string(pe.rpc_credits_per_hash) : "-")
|
2019-02-24 03:47:49 -05:00
|
|
|
<< " \tpruning seed " << pe.pruning_seed
|
2019-04-23 07:07:44 -04:00
|
|
|
<< " \tlast_seen: " << (pe.last_seen == 0 ? std::string("never") : epee::misc_utils::get_time_interval_string(now_time - pe.last_seen))
|
2019-02-24 03:47:49 -05:00
|
|
|
<< std::endl;
|
2014-03-03 17:07:58 -05:00
|
|
|
}
|
|
|
|
return ss.str();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct network_config
|
|
|
|
{
|
|
|
|
BEGIN_KV_SERIALIZE_MAP()
|
2018-01-20 01:36:19 -05:00
|
|
|
KV_SERIALIZE(max_out_connection_count)
|
2018-01-20 16:44:23 -05:00
|
|
|
KV_SERIALIZE(max_in_connection_count)
|
2014-03-03 17:07:58 -05:00
|
|
|
KV_SERIALIZE(handshake_interval)
|
|
|
|
KV_SERIALIZE(packet_max_size)
|
|
|
|
KV_SERIALIZE(config_id)
|
|
|
|
END_KV_SERIALIZE_MAP()
|
|
|
|
|
2018-01-20 01:36:19 -05:00
|
|
|
uint32_t max_out_connection_count;
|
2018-01-20 16:44:23 -05:00
|
|
|
uint32_t max_in_connection_count;
|
2014-03-20 07:46:11 -04:00
|
|
|
uint32_t connection_timeout;
|
|
|
|
uint32_t ping_connection_timeout;
|
|
|
|
uint32_t handshake_interval;
|
|
|
|
uint32_t packet_max_size;
|
|
|
|
uint32_t config_id;
|
|
|
|
uint32_t send_peerlist_sz;
|
2014-03-03 17:07:58 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
struct basic_node_data
|
|
|
|
{
|
|
|
|
uuid network_id;
|
2014-04-30 13:52:21 -04:00
|
|
|
uint64_t local_time;
|
2014-03-03 17:07:58 -05:00
|
|
|
uint32_t my_port;
|
2019-02-24 03:47:49 -05:00
|
|
|
uint16_t rpc_port;
|
daemon, wallet: new pay for RPC use system
Daemons intended for public use can be set up to require payment
in the form of hashes in exchange for RPC service. This enables
public daemons to receive payment for their work over a large
number of calls. This system behaves similarly to a pool, so
payment takes the form of valid blocks every so often, yielding
a large one off payment, rather than constant micropayments.
This system can also be used by third parties as a "paywall"
layer, where users of a service can pay for use by mining Monero
to the service provider's address. An example of this for web
site access is Primo, a Monero mining based website "paywall":
https://github.com/selene-kovri/primo
This has some advantages:
- incentive to run a node providing RPC services, thereby promoting the availability of third party nodes for those who can't run their own
- incentive to run your own node instead of using a third party's, thereby promoting decentralization
- decentralized: payment is done between a client and server, with no third party needed
- private: since the system is "pay as you go", you don't need to identify yourself to claim a long lived balance
- no payment occurs on the blockchain, so there is no extra transactional load
- one may mine with a beefy server, and use those credits from a phone, by reusing the client ID (at the cost of some privacy)
- no barrier to entry: anyone may run a RPC node, and your expected revenue depends on how much work you do
- Sybil resistant: if you run 1000 idle RPC nodes, you don't magically get more revenue
- no large credit balance maintained on servers, so they have no incentive to exit scam
- you can use any/many node(s), since there's little cost in switching servers
- market based prices: competition between servers to lower costs
- incentive for a distributed third party node system: if some public nodes are overused/slow, traffic can move to others
- increases network security
- helps counteract mining pools' share of the network hash rate
- zero incentive for a payer to "double spend" since a reorg does not give any money back to the miner
And some disadvantages:
- low power clients will have difficulty mining (but one can optionally mine in advance and/or with a faster machine)
- payment is "random", so a server might go a long time without a block before getting one
- a public node's overall expected payment may be small
Public nodes are expected to compete to find a suitable level for
cost of service.
The daemon can be set up this way to require payment for RPC services:
monerod --rpc-payment-address 4xxxxxx \
--rpc-payment-credits 250 --rpc-payment-difficulty 1000
These values are an example only.
The --rpc-payment-difficulty switch selects how hard each "share" should
be, similar to a mining pool. The higher the difficulty, the fewer
shares a client will find.
The --rpc-payment-credits switch selects how many credits are awarded
for each share a client finds.
Considering both options, clients will be awarded credits/difficulty
credits for every hash they calculate. For example, in the command line
above, 0.25 credits per hash. A client mining at 100 H/s will therefore
get an average of 25 credits per second.
For reference, in the current implementation, a credit is enough to
sync 20 blocks, so a 100 H/s client that's just starting to use Monero
and uses this daemon will be able to sync 500 blocks per second.
The wallet can be set to automatically mine if connected to a daemon
which requires payment for RPC usage. It will try to keep a balance
of 50000 credits, stopping mining when it's at this level, and starting
again as credits are spent. With the example above, a new client will
mine this much credits in about half an hour, and this target is enough
to sync 500000 blocks (currently about a third of the monero blockchain).
There are three new settings in the wallet:
- credits-target: this is the amount of credits a wallet will try to
reach before stopping mining. The default of 0 means 50000 credits.
- auto-mine-for-rpc-payment-threshold: this controls the minimum
credit rate which the wallet considers worth mining for. If the
daemon credits less than this ratio, the wallet will consider mining
to be not worth it. In the example above, the rate is 0.25
- persistent-rpc-client-id: if set, this allows the wallet to reuse
a client id across runs. This means a public node can tell a wallet
that's connecting is the same as one that connected previously, but
allows a wallet to keep their credit balance from one run to the
other. Since the wallet only mines to keep a small credit balance,
this is not normally worth doing. However, someone may want to mine
on a fast server, and use that credit balance on a low power device
such as a phone. If left unset, a new client ID is generated at
each wallet start, for privacy reasons.
To mine and use a credit balance on two different devices, you can
use the --rpc-client-secret-key switch. A wallet's client secret key
can be found using the new rpc_payments command in the wallet.
Note: anyone knowing your RPC client secret key is able to use your
credit balance.
The wallet has a few new commands too:
- start_mining_for_rpc: start mining to acquire more credits,
regardless of the auto mining settings
- stop_mining_for_rpc: stop mining to acquire more credits
- rpc_payments: display information about current credits with
the currently selected daemon
The node has an extra command:
- rpc_payments: display information about clients and their
balances
The node will forget about any balance for clients which have
been inactive for 6 months. Balances carry over on node restart.
2018-02-11 10:15:56 -05:00
|
|
|
uint32_t rpc_credits_per_hash;
|
2014-03-03 17:07:58 -05:00
|
|
|
peerid_type peer_id;
|
|
|
|
|
|
|
|
BEGIN_KV_SERIALIZE_MAP()
|
|
|
|
KV_SERIALIZE_VAL_POD_AS_BLOB(network_id)
|
|
|
|
KV_SERIALIZE(peer_id)
|
|
|
|
KV_SERIALIZE(local_time)
|
|
|
|
KV_SERIALIZE(my_port)
|
2019-02-24 03:47:49 -05:00
|
|
|
KV_SERIALIZE_OPT(rpc_port, (uint16_t)(0))
|
daemon, wallet: new pay for RPC use system
Daemons intended for public use can be set up to require payment
in the form of hashes in exchange for RPC service. This enables
public daemons to receive payment for their work over a large
number of calls. This system behaves similarly to a pool, so
payment takes the form of valid blocks every so often, yielding
a large one off payment, rather than constant micropayments.
This system can also be used by third parties as a "paywall"
layer, where users of a service can pay for use by mining Monero
to the service provider's address. An example of this for web
site access is Primo, a Monero mining based website "paywall":
https://github.com/selene-kovri/primo
This has some advantages:
- incentive to run a node providing RPC services, thereby promoting the availability of third party nodes for those who can't run their own
- incentive to run your own node instead of using a third party's, thereby promoting decentralization
- decentralized: payment is done between a client and server, with no third party needed
- private: since the system is "pay as you go", you don't need to identify yourself to claim a long lived balance
- no payment occurs on the blockchain, so there is no extra transactional load
- one may mine with a beefy server, and use those credits from a phone, by reusing the client ID (at the cost of some privacy)
- no barrier to entry: anyone may run a RPC node, and your expected revenue depends on how much work you do
- Sybil resistant: if you run 1000 idle RPC nodes, you don't magically get more revenue
- no large credit balance maintained on servers, so they have no incentive to exit scam
- you can use any/many node(s), since there's little cost in switching servers
- market based prices: competition between servers to lower costs
- incentive for a distributed third party node system: if some public nodes are overused/slow, traffic can move to others
- increases network security
- helps counteract mining pools' share of the network hash rate
- zero incentive for a payer to "double spend" since a reorg does not give any money back to the miner
And some disadvantages:
- low power clients will have difficulty mining (but one can optionally mine in advance and/or with a faster machine)
- payment is "random", so a server might go a long time without a block before getting one
- a public node's overall expected payment may be small
Public nodes are expected to compete to find a suitable level for
cost of service.
The daemon can be set up this way to require payment for RPC services:
monerod --rpc-payment-address 4xxxxxx \
--rpc-payment-credits 250 --rpc-payment-difficulty 1000
These values are an example only.
The --rpc-payment-difficulty switch selects how hard each "share" should
be, similar to a mining pool. The higher the difficulty, the fewer
shares a client will find.
The --rpc-payment-credits switch selects how many credits are awarded
for each share a client finds.
Considering both options, clients will be awarded credits/difficulty
credits for every hash they calculate. For example, in the command line
above, 0.25 credits per hash. A client mining at 100 H/s will therefore
get an average of 25 credits per second.
For reference, in the current implementation, a credit is enough to
sync 20 blocks, so a 100 H/s client that's just starting to use Monero
and uses this daemon will be able to sync 500 blocks per second.
The wallet can be set to automatically mine if connected to a daemon
which requires payment for RPC usage. It will try to keep a balance
of 50000 credits, stopping mining when it's at this level, and starting
again as credits are spent. With the example above, a new client will
mine this much credits in about half an hour, and this target is enough
to sync 500000 blocks (currently about a third of the monero blockchain).
There are three new settings in the wallet:
- credits-target: this is the amount of credits a wallet will try to
reach before stopping mining. The default of 0 means 50000 credits.
- auto-mine-for-rpc-payment-threshold: this controls the minimum
credit rate which the wallet considers worth mining for. If the
daemon credits less than this ratio, the wallet will consider mining
to be not worth it. In the example above, the rate is 0.25
- persistent-rpc-client-id: if set, this allows the wallet to reuse
a client id across runs. This means a public node can tell a wallet
that's connecting is the same as one that connected previously, but
allows a wallet to keep their credit balance from one run to the
other. Since the wallet only mines to keep a small credit balance,
this is not normally worth doing. However, someone may want to mine
on a fast server, and use that credit balance on a low power device
such as a phone. If left unset, a new client ID is generated at
each wallet start, for privacy reasons.
To mine and use a credit balance on two different devices, you can
use the --rpc-client-secret-key switch. A wallet's client secret key
can be found using the new rpc_payments command in the wallet.
Note: anyone knowing your RPC client secret key is able to use your
credit balance.
The wallet has a few new commands too:
- start_mining_for_rpc: start mining to acquire more credits,
regardless of the auto mining settings
- stop_mining_for_rpc: stop mining to acquire more credits
- rpc_payments: display information about current credits with
the currently selected daemon
The node has an extra command:
- rpc_payments: display information about clients and their
balances
The node will forget about any balance for clients which have
been inactive for 6 months. Balances carry over on node restart.
2018-02-11 10:15:56 -05:00
|
|
|
KV_SERIALIZE_OPT(rpc_credits_per_hash, (uint32_t)0)
|
2014-03-03 17:07:58 -05:00
|
|
|
END_KV_SERIALIZE_MAP()
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#define P2P_COMMANDS_POOL_BASE 1000
|
|
|
|
|
|
|
|
/************************************************************************/
|
|
|
|
/* */
|
|
|
|
/************************************************************************/
|
|
|
|
template<class t_playload_type>
|
|
|
|
struct COMMAND_HANDSHAKE_T
|
|
|
|
{
|
|
|
|
const static int ID = P2P_COMMANDS_POOL_BASE + 1;
|
|
|
|
|
2019-01-17 20:05:58 -05:00
|
|
|
struct request_t
|
2014-03-03 17:07:58 -05:00
|
|
|
{
|
|
|
|
basic_node_data node_data;
|
|
|
|
t_playload_type payload_data;
|
|
|
|
|
|
|
|
BEGIN_KV_SERIALIZE_MAP()
|
|
|
|
KV_SERIALIZE(node_data)
|
|
|
|
KV_SERIALIZE(payload_data)
|
|
|
|
END_KV_SERIALIZE_MAP()
|
|
|
|
};
|
2019-01-17 20:05:58 -05:00
|
|
|
typedef epee::misc_utils::struct_init<request_t> request;
|
2014-03-03 17:07:58 -05:00
|
|
|
|
2019-01-17 20:05:58 -05:00
|
|
|
struct response_t
|
2014-03-03 17:07:58 -05:00
|
|
|
{
|
|
|
|
basic_node_data node_data;
|
|
|
|
t_playload_type payload_data;
|
2018-12-05 17:25:27 -05:00
|
|
|
std::vector<peerlist_entry> local_peerlist_new;
|
2014-03-03 17:07:58 -05:00
|
|
|
|
|
|
|
BEGIN_KV_SERIALIZE_MAP()
|
|
|
|
KV_SERIALIZE(node_data)
|
|
|
|
KV_SERIALIZE(payload_data)
|
2017-05-27 06:35:54 -04:00
|
|
|
if (is_store)
|
|
|
|
{
|
|
|
|
// saving: save both, so old and new peers can understand it
|
|
|
|
KV_SERIALIZE(local_peerlist_new)
|
2018-12-05 17:25:27 -05:00
|
|
|
std::vector<peerlist_entry_base<network_address_old>> local_peerlist;
|
2017-05-27 06:35:54 -04:00
|
|
|
for (const auto &p: this_ref.local_peerlist_new)
|
|
|
|
{
|
2018-12-16 12:57:44 -05:00
|
|
|
if (p.adr.get_type_id() == epee::net_utils::ipv4_network_address::get_type_id())
|
2017-05-27 06:35:54 -04:00
|
|
|
{
|
|
|
|
const epee::net_utils::network_address &na = p.adr;
|
|
|
|
const epee::net_utils::ipv4_network_address &ipv4 = na.as<const epee::net_utils::ipv4_network_address>();
|
daemon, wallet: new pay for RPC use system
Daemons intended for public use can be set up to require payment
in the form of hashes in exchange for RPC service. This enables
public daemons to receive payment for their work over a large
number of calls. This system behaves similarly to a pool, so
payment takes the form of valid blocks every so often, yielding
a large one off payment, rather than constant micropayments.
This system can also be used by third parties as a "paywall"
layer, where users of a service can pay for use by mining Monero
to the service provider's address. An example of this for web
site access is Primo, a Monero mining based website "paywall":
https://github.com/selene-kovri/primo
This has some advantages:
- incentive to run a node providing RPC services, thereby promoting the availability of third party nodes for those who can't run their own
- incentive to run your own node instead of using a third party's, thereby promoting decentralization
- decentralized: payment is done between a client and server, with no third party needed
- private: since the system is "pay as you go", you don't need to identify yourself to claim a long lived balance
- no payment occurs on the blockchain, so there is no extra transactional load
- one may mine with a beefy server, and use those credits from a phone, by reusing the client ID (at the cost of some privacy)
- no barrier to entry: anyone may run a RPC node, and your expected revenue depends on how much work you do
- Sybil resistant: if you run 1000 idle RPC nodes, you don't magically get more revenue
- no large credit balance maintained on servers, so they have no incentive to exit scam
- you can use any/many node(s), since there's little cost in switching servers
- market based prices: competition between servers to lower costs
- incentive for a distributed third party node system: if some public nodes are overused/slow, traffic can move to others
- increases network security
- helps counteract mining pools' share of the network hash rate
- zero incentive for a payer to "double spend" since a reorg does not give any money back to the miner
And some disadvantages:
- low power clients will have difficulty mining (but one can optionally mine in advance and/or with a faster machine)
- payment is "random", so a server might go a long time without a block before getting one
- a public node's overall expected payment may be small
Public nodes are expected to compete to find a suitable level for
cost of service.
The daemon can be set up this way to require payment for RPC services:
monerod --rpc-payment-address 4xxxxxx \
--rpc-payment-credits 250 --rpc-payment-difficulty 1000
These values are an example only.
The --rpc-payment-difficulty switch selects how hard each "share" should
be, similar to a mining pool. The higher the difficulty, the fewer
shares a client will find.
The --rpc-payment-credits switch selects how many credits are awarded
for each share a client finds.
Considering both options, clients will be awarded credits/difficulty
credits for every hash they calculate. For example, in the command line
above, 0.25 credits per hash. A client mining at 100 H/s will therefore
get an average of 25 credits per second.
For reference, in the current implementation, a credit is enough to
sync 20 blocks, so a 100 H/s client that's just starting to use Monero
and uses this daemon will be able to sync 500 blocks per second.
The wallet can be set to automatically mine if connected to a daemon
which requires payment for RPC usage. It will try to keep a balance
of 50000 credits, stopping mining when it's at this level, and starting
again as credits are spent. With the example above, a new client will
mine this much credits in about half an hour, and this target is enough
to sync 500000 blocks (currently about a third of the monero blockchain).
There are three new settings in the wallet:
- credits-target: this is the amount of credits a wallet will try to
reach before stopping mining. The default of 0 means 50000 credits.
- auto-mine-for-rpc-payment-threshold: this controls the minimum
credit rate which the wallet considers worth mining for. If the
daemon credits less than this ratio, the wallet will consider mining
to be not worth it. In the example above, the rate is 0.25
- persistent-rpc-client-id: if set, this allows the wallet to reuse
a client id across runs. This means a public node can tell a wallet
that's connecting is the same as one that connected previously, but
allows a wallet to keep their credit balance from one run to the
other. Since the wallet only mines to keep a small credit balance,
this is not normally worth doing. However, someone may want to mine
on a fast server, and use that credit balance on a low power device
such as a phone. If left unset, a new client ID is generated at
each wallet start, for privacy reasons.
To mine and use a credit balance on two different devices, you can
use the --rpc-client-secret-key switch. A wallet's client secret key
can be found using the new rpc_payments command in the wallet.
Note: anyone knowing your RPC client secret key is able to use your
credit balance.
The wallet has a few new commands too:
- start_mining_for_rpc: start mining to acquire more credits,
regardless of the auto mining settings
- stop_mining_for_rpc: stop mining to acquire more credits
- rpc_payments: display information about current credits with
the currently selected daemon
The node has an extra command:
- rpc_payments: display information about clients and their
balances
The node will forget about any balance for clients which have
been inactive for 6 months. Balances carry over on node restart.
2018-02-11 10:15:56 -05:00
|
|
|
local_peerlist.push_back(peerlist_entry_base<network_address_old>({{ipv4.ip(), ipv4.port()}, p.id, p.last_seen, p.pruning_seed, p.rpc_port, p.rpc_credits_per_hash}));
|
2017-05-27 06:35:54 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
MDEBUG("Not including in legacy peer list: " << p.adr.str());
|
|
|
|
}
|
|
|
|
epee::serialization::selector<is_store>::serialize_stl_container_pod_val_as_blob(local_peerlist, stg, hparent_section, "local_peerlist");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// loading: load old list only if there is no new one
|
|
|
|
if (!epee::serialization::selector<is_store>::serialize(this_ref.local_peerlist_new, stg, hparent_section, "local_peerlist_new"))
|
|
|
|
{
|
2018-12-05 17:25:27 -05:00
|
|
|
std::vector<peerlist_entry_base<network_address_old>> local_peerlist;
|
2017-05-27 06:35:54 -04:00
|
|
|
epee::serialization::selector<is_store>::serialize_stl_container_pod_val_as_blob(local_peerlist, stg, hparent_section, "local_peerlist");
|
|
|
|
for (const auto &p: local_peerlist)
|
daemon, wallet: new pay for RPC use system
Daemons intended for public use can be set up to require payment
in the form of hashes in exchange for RPC service. This enables
public daemons to receive payment for their work over a large
number of calls. This system behaves similarly to a pool, so
payment takes the form of valid blocks every so often, yielding
a large one off payment, rather than constant micropayments.
This system can also be used by third parties as a "paywall"
layer, where users of a service can pay for use by mining Monero
to the service provider's address. An example of this for web
site access is Primo, a Monero mining based website "paywall":
https://github.com/selene-kovri/primo
This has some advantages:
- incentive to run a node providing RPC services, thereby promoting the availability of third party nodes for those who can't run their own
- incentive to run your own node instead of using a third party's, thereby promoting decentralization
- decentralized: payment is done between a client and server, with no third party needed
- private: since the system is "pay as you go", you don't need to identify yourself to claim a long lived balance
- no payment occurs on the blockchain, so there is no extra transactional load
- one may mine with a beefy server, and use those credits from a phone, by reusing the client ID (at the cost of some privacy)
- no barrier to entry: anyone may run a RPC node, and your expected revenue depends on how much work you do
- Sybil resistant: if you run 1000 idle RPC nodes, you don't magically get more revenue
- no large credit balance maintained on servers, so they have no incentive to exit scam
- you can use any/many node(s), since there's little cost in switching servers
- market based prices: competition between servers to lower costs
- incentive for a distributed third party node system: if some public nodes are overused/slow, traffic can move to others
- increases network security
- helps counteract mining pools' share of the network hash rate
- zero incentive for a payer to "double spend" since a reorg does not give any money back to the miner
And some disadvantages:
- low power clients will have difficulty mining (but one can optionally mine in advance and/or with a faster machine)
- payment is "random", so a server might go a long time without a block before getting one
- a public node's overall expected payment may be small
Public nodes are expected to compete to find a suitable level for
cost of service.
The daemon can be set up this way to require payment for RPC services:
monerod --rpc-payment-address 4xxxxxx \
--rpc-payment-credits 250 --rpc-payment-difficulty 1000
These values are an example only.
The --rpc-payment-difficulty switch selects how hard each "share" should
be, similar to a mining pool. The higher the difficulty, the fewer
shares a client will find.
The --rpc-payment-credits switch selects how many credits are awarded
for each share a client finds.
Considering both options, clients will be awarded credits/difficulty
credits for every hash they calculate. For example, in the command line
above, 0.25 credits per hash. A client mining at 100 H/s will therefore
get an average of 25 credits per second.
For reference, in the current implementation, a credit is enough to
sync 20 blocks, so a 100 H/s client that's just starting to use Monero
and uses this daemon will be able to sync 500 blocks per second.
The wallet can be set to automatically mine if connected to a daemon
which requires payment for RPC usage. It will try to keep a balance
of 50000 credits, stopping mining when it's at this level, and starting
again as credits are spent. With the example above, a new client will
mine this much credits in about half an hour, and this target is enough
to sync 500000 blocks (currently about a third of the monero blockchain).
There are three new settings in the wallet:
- credits-target: this is the amount of credits a wallet will try to
reach before stopping mining. The default of 0 means 50000 credits.
- auto-mine-for-rpc-payment-threshold: this controls the minimum
credit rate which the wallet considers worth mining for. If the
daemon credits less than this ratio, the wallet will consider mining
to be not worth it. In the example above, the rate is 0.25
- persistent-rpc-client-id: if set, this allows the wallet to reuse
a client id across runs. This means a public node can tell a wallet
that's connecting is the same as one that connected previously, but
allows a wallet to keep their credit balance from one run to the
other. Since the wallet only mines to keep a small credit balance,
this is not normally worth doing. However, someone may want to mine
on a fast server, and use that credit balance on a low power device
such as a phone. If left unset, a new client ID is generated at
each wallet start, for privacy reasons.
To mine and use a credit balance on two different devices, you can
use the --rpc-client-secret-key switch. A wallet's client secret key
can be found using the new rpc_payments command in the wallet.
Note: anyone knowing your RPC client secret key is able to use your
credit balance.
The wallet has a few new commands too:
- start_mining_for_rpc: start mining to acquire more credits,
regardless of the auto mining settings
- stop_mining_for_rpc: stop mining to acquire more credits
- rpc_payments: display information about current credits with
the currently selected daemon
The node has an extra command:
- rpc_payments: display information about clients and their
balances
The node will forget about any balance for clients which have
been inactive for 6 months. Balances carry over on node restart.
2018-02-11 10:15:56 -05:00
|
|
|
((response&)this_ref).local_peerlist_new.push_back(peerlist_entry({epee::net_utils::ipv4_network_address(p.adr.ip, p.adr.port), p.id, p.last_seen, p.pruning_seed, p.rpc_port, p.rpc_credits_per_hash}));
|
2017-05-27 06:35:54 -04:00
|
|
|
}
|
|
|
|
}
|
2014-03-03 17:07:58 -05:00
|
|
|
END_KV_SERIALIZE_MAP()
|
|
|
|
};
|
2019-01-17 20:05:58 -05:00
|
|
|
typedef epee::misc_utils::struct_init<response_t> response;
|
|
|
|
};
|
2014-03-03 17:07:58 -05:00
|
|
|
|
|
|
|
|
|
|
|
/************************************************************************/
|
|
|
|
/* */
|
|
|
|
/************************************************************************/
|
|
|
|
template<class t_playload_type>
|
|
|
|
struct COMMAND_TIMED_SYNC_T
|
|
|
|
{
|
|
|
|
const static int ID = P2P_COMMANDS_POOL_BASE + 2;
|
|
|
|
|
2019-01-17 20:05:58 -05:00
|
|
|
struct request_t
|
2014-03-03 17:07:58 -05:00
|
|
|
{
|
|
|
|
t_playload_type payload_data;
|
|
|
|
BEGIN_KV_SERIALIZE_MAP()
|
|
|
|
KV_SERIALIZE(payload_data)
|
|
|
|
END_KV_SERIALIZE_MAP()
|
|
|
|
};
|
2019-01-17 20:05:58 -05:00
|
|
|
typedef epee::misc_utils::struct_init<request_t> request;
|
2014-03-03 17:07:58 -05:00
|
|
|
|
2019-01-17 20:05:58 -05:00
|
|
|
struct response_t
|
2014-03-03 17:07:58 -05:00
|
|
|
{
|
|
|
|
t_playload_type payload_data;
|
2018-12-05 17:25:27 -05:00
|
|
|
std::vector<peerlist_entry> local_peerlist_new;
|
2014-03-03 17:07:58 -05:00
|
|
|
|
|
|
|
BEGIN_KV_SERIALIZE_MAP()
|
|
|
|
KV_SERIALIZE(payload_data)
|
2017-05-27 06:35:54 -04:00
|
|
|
if (is_store)
|
|
|
|
{
|
|
|
|
// saving: save both, so old and new peers can understand it
|
|
|
|
KV_SERIALIZE(local_peerlist_new)
|
2018-12-05 17:25:27 -05:00
|
|
|
std::vector<peerlist_entry_base<network_address_old>> local_peerlist;
|
2017-05-27 06:35:54 -04:00
|
|
|
for (const auto &p: this_ref.local_peerlist_new)
|
|
|
|
{
|
2018-12-16 12:57:44 -05:00
|
|
|
if (p.adr.get_type_id() == epee::net_utils::ipv4_network_address::get_type_id())
|
2017-05-27 06:35:54 -04:00
|
|
|
{
|
|
|
|
const epee::net_utils::network_address &na = p.adr;
|
|
|
|
const epee::net_utils::ipv4_network_address &ipv4 = na.as<const epee::net_utils::ipv4_network_address>();
|
|
|
|
local_peerlist.push_back(peerlist_entry_base<network_address_old>({{ipv4.ip(), ipv4.port()}, p.id, p.last_seen}));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
MDEBUG("Not including in legacy peer list: " << p.adr.str());
|
|
|
|
}
|
|
|
|
epee::serialization::selector<is_store>::serialize_stl_container_pod_val_as_blob(local_peerlist, stg, hparent_section, "local_peerlist");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// loading: load old list only if there is no new one
|
|
|
|
if (!epee::serialization::selector<is_store>::serialize(this_ref.local_peerlist_new, stg, hparent_section, "local_peerlist_new"))
|
|
|
|
{
|
2018-12-05 17:25:27 -05:00
|
|
|
std::vector<peerlist_entry_base<network_address_old>> local_peerlist;
|
2017-05-27 06:35:54 -04:00
|
|
|
epee::serialization::selector<is_store>::serialize_stl_container_pod_val_as_blob(local_peerlist, stg, hparent_section, "local_peerlist");
|
|
|
|
for (const auto &p: local_peerlist)
|
2017-08-25 11:14:46 -04:00
|
|
|
((response&)this_ref).local_peerlist_new.push_back(peerlist_entry({epee::net_utils::ipv4_network_address(p.adr.ip, p.adr.port), p.id, p.last_seen}));
|
2017-05-27 06:35:54 -04:00
|
|
|
}
|
|
|
|
}
|
2014-03-03 17:07:58 -05:00
|
|
|
END_KV_SERIALIZE_MAP()
|
|
|
|
};
|
2019-01-17 20:05:58 -05:00
|
|
|
typedef epee::misc_utils::struct_init<response_t> response;
|
2014-03-03 17:07:58 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
/************************************************************************/
|
|
|
|
/* */
|
|
|
|
/************************************************************************/
|
|
|
|
|
|
|
|
struct COMMAND_PING
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
Used to make "callback" connection, to be sure that opponent node
|
|
|
|
have accessible connection point. Only other nodes can add peer to peerlist,
|
|
|
|
and ONLY in case when peer has accepted connection and answered to ping.
|
|
|
|
*/
|
|
|
|
const static int ID = P2P_COMMANDS_POOL_BASE + 3;
|
|
|
|
|
|
|
|
#define PING_OK_RESPONSE_STATUS_TEXT "OK"
|
|
|
|
|
2019-01-17 20:05:58 -05:00
|
|
|
struct request_t
|
2014-03-03 17:07:58 -05:00
|
|
|
{
|
|
|
|
/*actually we don't need to send any real data*/
|
|
|
|
|
|
|
|
BEGIN_KV_SERIALIZE_MAP()
|
|
|
|
END_KV_SERIALIZE_MAP()
|
|
|
|
};
|
2019-01-17 20:05:58 -05:00
|
|
|
typedef epee::misc_utils::struct_init<request_t> request;
|
2014-03-03 17:07:58 -05:00
|
|
|
|
2019-01-17 20:05:58 -05:00
|
|
|
struct response_t
|
2014-03-03 17:07:58 -05:00
|
|
|
{
|
|
|
|
std::string status;
|
|
|
|
peerid_type peer_id;
|
|
|
|
|
|
|
|
BEGIN_KV_SERIALIZE_MAP()
|
|
|
|
KV_SERIALIZE(status)
|
|
|
|
KV_SERIALIZE(peer_id)
|
|
|
|
END_KV_SERIALIZE_MAP()
|
|
|
|
};
|
2019-01-17 20:05:58 -05:00
|
|
|
typedef epee::misc_utils::struct_init<response_t> response;
|
2014-03-03 17:07:58 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef ALLOW_DEBUG_COMMANDS
|
|
|
|
//These commands are considered as insecure, and made in debug purposes for a limited lifetime.
|
|
|
|
//Anyone who feel unsafe with this commands can disable the ALLOW_GET_STAT_COMMAND macro.
|
|
|
|
|
|
|
|
struct proof_of_trust
|
|
|
|
{
|
|
|
|
peerid_type peer_id;
|
|
|
|
uint64_t time;
|
|
|
|
crypto::signature sign;
|
|
|
|
|
|
|
|
BEGIN_KV_SERIALIZE_MAP()
|
|
|
|
KV_SERIALIZE(peer_id)
|
|
|
|
KV_SERIALIZE(time)
|
|
|
|
KV_SERIALIZE_VAL_POD_AS_BLOB(sign)
|
|
|
|
END_KV_SERIALIZE_MAP()
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template<class payload_stat_info>
|
|
|
|
struct COMMAND_REQUEST_STAT_INFO_T
|
|
|
|
{
|
|
|
|
const static int ID = P2P_COMMANDS_POOL_BASE + 4;
|
|
|
|
|
2019-01-17 20:05:58 -05:00
|
|
|
struct request_t
|
2014-03-03 17:07:58 -05:00
|
|
|
{
|
|
|
|
proof_of_trust tr;
|
|
|
|
BEGIN_KV_SERIALIZE_MAP()
|
|
|
|
KV_SERIALIZE(tr)
|
|
|
|
END_KV_SERIALIZE_MAP()
|
|
|
|
};
|
2019-01-17 20:05:58 -05:00
|
|
|
typedef epee::misc_utils::struct_init<request_t> request;
|
2014-03-03 17:07:58 -05:00
|
|
|
|
2019-01-17 20:05:58 -05:00
|
|
|
struct response_t
|
2014-03-03 17:07:58 -05:00
|
|
|
{
|
|
|
|
std::string version;
|
|
|
|
std::string os_version;
|
|
|
|
uint64_t connections_count;
|
|
|
|
uint64_t incoming_connections_count;
|
|
|
|
payload_stat_info payload_info;
|
|
|
|
|
|
|
|
BEGIN_KV_SERIALIZE_MAP()
|
|
|
|
KV_SERIALIZE(version)
|
|
|
|
KV_SERIALIZE(os_version)
|
|
|
|
KV_SERIALIZE(connections_count)
|
|
|
|
KV_SERIALIZE(incoming_connections_count)
|
|
|
|
KV_SERIALIZE(payload_info)
|
|
|
|
END_KV_SERIALIZE_MAP()
|
|
|
|
};
|
2019-01-17 20:05:58 -05:00
|
|
|
typedef epee::misc_utils::struct_init<response_t> response;
|
2014-03-03 17:07:58 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************************************/
|
|
|
|
/* */
|
|
|
|
/************************************************************************/
|
|
|
|
struct COMMAND_REQUEST_NETWORK_STATE
|
|
|
|
{
|
|
|
|
const static int ID = P2P_COMMANDS_POOL_BASE + 5;
|
|
|
|
|
2019-01-17 20:05:58 -05:00
|
|
|
struct request_t
|
2014-03-03 17:07:58 -05:00
|
|
|
{
|
|
|
|
proof_of_trust tr;
|
|
|
|
BEGIN_KV_SERIALIZE_MAP()
|
|
|
|
KV_SERIALIZE(tr)
|
|
|
|
END_KV_SERIALIZE_MAP()
|
|
|
|
};
|
2019-01-17 20:05:58 -05:00
|
|
|
typedef epee::misc_utils::struct_init<request_t> request;
|
2014-03-03 17:07:58 -05:00
|
|
|
|
2019-01-17 20:05:58 -05:00
|
|
|
struct response_t
|
2014-03-03 17:07:58 -05:00
|
|
|
{
|
2018-12-05 17:25:27 -05:00
|
|
|
std::vector<peerlist_entry> local_peerlist_white;
|
|
|
|
std::vector<peerlist_entry> local_peerlist_gray;
|
|
|
|
std::vector<connection_entry> connections_list;
|
2014-03-03 17:07:58 -05:00
|
|
|
peerid_type my_id;
|
|
|
|
uint64_t local_time;
|
|
|
|
BEGIN_KV_SERIALIZE_MAP()
|
|
|
|
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(local_peerlist_white)
|
|
|
|
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(local_peerlist_gray)
|
|
|
|
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(connections_list)
|
|
|
|
KV_SERIALIZE(my_id)
|
|
|
|
KV_SERIALIZE(local_time)
|
|
|
|
END_KV_SERIALIZE_MAP()
|
|
|
|
};
|
2019-01-17 20:05:58 -05:00
|
|
|
typedef epee::misc_utils::struct_init<response_t> response;
|
2014-03-03 17:07:58 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
/************************************************************************/
|
|
|
|
/* */
|
|
|
|
/************************************************************************/
|
|
|
|
struct COMMAND_REQUEST_PEER_ID
|
|
|
|
{
|
|
|
|
const static int ID = P2P_COMMANDS_POOL_BASE + 6;
|
|
|
|
|
2019-01-17 20:05:58 -05:00
|
|
|
struct request_t
|
2014-03-03 17:07:58 -05:00
|
|
|
{
|
|
|
|
BEGIN_KV_SERIALIZE_MAP()
|
|
|
|
END_KV_SERIALIZE_MAP()
|
|
|
|
};
|
2019-01-17 20:05:58 -05:00
|
|
|
typedef epee::misc_utils::struct_init<request_t> request;
|
2014-03-03 17:07:58 -05:00
|
|
|
|
2019-01-17 20:05:58 -05:00
|
|
|
struct response_t
|
2014-03-03 17:07:58 -05:00
|
|
|
{
|
|
|
|
peerid_type my_id;
|
|
|
|
|
|
|
|
BEGIN_KV_SERIALIZE_MAP()
|
|
|
|
KV_SERIALIZE(my_id)
|
|
|
|
END_KV_SERIALIZE_MAP()
|
|
|
|
};
|
2019-01-17 20:05:58 -05:00
|
|
|
typedef epee::misc_utils::struct_init<response_t> response;
|
2014-03-03 17:07:58 -05:00
|
|
|
};
|
|
|
|
|
2016-10-26 15:00:08 -04:00
|
|
|
/************************************************************************/
|
|
|
|
/* */
|
|
|
|
/************************************************************************/
|
|
|
|
struct COMMAND_REQUEST_SUPPORT_FLAGS
|
|
|
|
{
|
|
|
|
const static int ID = P2P_COMMANDS_POOL_BASE + 7;
|
|
|
|
|
2019-01-17 20:05:58 -05:00
|
|
|
struct request_t
|
2016-10-26 15:00:08 -04:00
|
|
|
{
|
|
|
|
BEGIN_KV_SERIALIZE_MAP()
|
|
|
|
END_KV_SERIALIZE_MAP()
|
|
|
|
};
|
2019-01-17 20:05:58 -05:00
|
|
|
typedef epee::misc_utils::struct_init<request_t> request;
|
2016-10-26 15:00:08 -04:00
|
|
|
|
2019-01-17 20:05:58 -05:00
|
|
|
struct response_t
|
2016-10-26 15:00:08 -04:00
|
|
|
{
|
|
|
|
uint32_t support_flags;
|
|
|
|
|
|
|
|
BEGIN_KV_SERIALIZE_MAP()
|
|
|
|
KV_SERIALIZE(support_flags)
|
|
|
|
END_KV_SERIALIZE_MAP()
|
|
|
|
};
|
2019-01-17 20:05:58 -05:00
|
|
|
typedef epee::misc_utils::struct_init<response_t> response;
|
2016-10-26 15:00:08 -04:00
|
|
|
};
|
|
|
|
|
2014-03-03 17:07:58 -05:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2017-07-27 10:46:47 -04:00
|
|
|
inline crypto::hash get_proof_of_trust_hash(const nodetool::proof_of_trust& pot)
|
|
|
|
{
|
|
|
|
std::string s;
|
|
|
|
s.append(reinterpret_cast<const char*>(&pot.peer_id), sizeof(pot.peer_id));
|
|
|
|
s.append(reinterpret_cast<const char*>(&pot.time), sizeof(pot.time));
|
|
|
|
return crypto::cn_fast_hash(s.data(), s.size());
|
|
|
|
}
|
|
|
|
|
2014-03-03 17:07:58 -05:00
|
|
|
}
|