Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/avalanche.cpp
// Copyright (c) 2020 The Bitcoin developers | // Copyright (c) 2020 The Bitcoin developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <avalanche/delegationbuilder.h> | |||||
#include <avalanche/processor.h> | #include <avalanche/processor.h> | ||||
#include <avalanche/proof.h> | #include <avalanche/proof.h> | ||||
#include <avalanche/proofbuilder.h> | #include <avalanche/proofbuilder.h> | ||||
#include <config.h> | #include <config.h> | ||||
#include <key_io.h> | #include <key_io.h> | ||||
#include <rpc/server.h> | #include <rpc/server.h> | ||||
#include <rpc/util.h> | #include <rpc/util.h> | ||||
#include <util/strencodings.h> | #include <util/strencodings.h> | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | static UniValue addavalanchenode(const Config &config, | ||||
const NodeId nodeid = request.params[0].get_int64(); | const NodeId nodeid = request.params[0].get_int64(); | ||||
const CPubKey key = ParsePubKey(request.params[1]); | const CPubKey key = ParsePubKey(request.params[1]); | ||||
CDataStream ss(ParseHexV(request.params[2], "proof"), SER_NETWORK, | CDataStream ss(ParseHexV(request.params[2], "proof"), SER_NETWORK, | ||||
PROTOCOL_VERSION); | PROTOCOL_VERSION); | ||||
avalanche::Proof proof; | avalanche::Proof proof; | ||||
ss >> proof; | ss >> proof; | ||||
return g_avalanche->addNode(nodeid, proof, key); | if (key != proof.getMaster()) { | ||||
// TODO: we want to provide a proper delegation. | |||||
return false; | |||||
} | |||||
return g_avalanche->addNode(nodeid, proof, | |||||
avalanche::DelegationBuilder(proof).build()); | |||||
} | } | ||||
static UniValue buildavalancheproof(const Config &config, | static UniValue buildavalancheproof(const Config &config, | ||||
const JSONRPCRequest &request) { | const JSONRPCRequest &request) { | ||||
RPCHelpMan{ | RPCHelpMan{ | ||||
"buildavalancheproof", | "buildavalancheproof", | ||||
"Build a proof for avalanche's sybil resistance.\n", | "Build a proof for avalanche's sybil resistance.\n", | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 124 Lines • Show Last 20 Lines |