Skip to content
This repository has been archived by the owner on Oct 4, 2019. It is now read-only.

Ban list #69

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions libraries/chain/hardfork.d/0_17.hf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#ifndef STEEMIT_HARDFORK_0_17
#define STEEMIT_HARDFORK_0_17 17
#endif
7 changes: 7 additions & 0 deletions libraries/chain/include/steemit/chain/account_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,11 @@ namespace steemit {
allocator<change_recovery_account_request_object>
>
change_recovery_account_request_index;

struct account_metadata {
set<string> ban_list;
};

}
}

Expand Down Expand Up @@ -454,3 +459,5 @@ FC_REFLECT(steemit::chain::change_recovery_account_request_object,
(id)(account_to_recover)(recovery_account)(effective_on)
)
CHAINBASE_SET_INDEX_TYPE(steemit::chain::change_recovery_account_request_object, steemit::chain::change_recovery_account_request_index)

FC_REFLECT(steemit::chain::account_metadata, (ban_list));
23 changes: 23 additions & 0 deletions libraries/chain/steem_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#include <steemit/chain/steem_objects.hpp>
#include <steemit/chain/block_summary_object.hpp>

#include <fc/io/json.hpp>
#include <fc/string.hpp>

#ifndef IS_LOW_MEM

#include <diff_match_patch.h>
Expand Down Expand Up @@ -399,6 +402,26 @@ namespace steemit {
parent = &_db.get_comment(o.parent_author, o.parent_permlink);
FC_ASSERT(parent->depth <
STEEMIT_MAX_COMMENT_DEPTH, "Comment is nested ${x} posts deep, maximum depth is ${y}.", ("x", parent->depth)("y", STEEMIT_MAX_COMMENT_DEPTH));


// check root author ban list
if (_db.has_hardfork(STEEMIT_HARDFORK_0_17)) {
const comment_object root(_db.get<comment_object>(parent->root_comment));
const account_object root_acc(_db.get_account(root.author));
account_metadata meta;
if (root_acc.json_metadata.size())
{
try
{
meta = fc::json::from_string( to_string( root_acc.json_metadata ) ).as< account_metadata >();
FC_ASSERT( std::find(meta.ban_list.begin(), meta.ban_list.end(), o.author) == meta.ban_list.end(), "Author added your account to ban list" );
}
catch( const fc::exception& e )
{
// Do nothing on malformed json_metadata
}
}
}
}
auto now = _db.head_block_time();

Expand Down