{"action":"created","issue":{"url":"https://api.github.com/repos/bitcoin/bitcoin/issues/5595","labels_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/5595/labels{/name}","comments_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/5595/comments","events_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/5595/events","html_url":"https://github.com/bitcoin/bitcoin/pull/5595","id":53307229,"number":5595,"title":"Policy: Create CPolicy interface and CStandardPolicy class implementing it","user":{"login":"jtimon","id":1008458,"avatar_url":"https://avatars.githubusercontent.com/u/1008458?v=3","gravatar_id":"","url":"https://api.github.com/users/jtimon","html_url":"https://github.com/jtimon","followers_url":"https://api.github.com/users/jtimon/followers","following_url":"https://api.github.com/users/jtimon/following{/other_user}","gists_url":"https://api.github.com/users/jtimon/gists{/gist_id}","starred_url":"https://api.github.com/users/jtimon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jtimon/subscriptions","organizations_url":"https://api.github.com/users/jtimon/orgs","repos_url":"https://api.github.com/users/jtimon/repos","events_url":"https://api.github.com/users/jtimon/events{/privacy}","received_events_url":"https://api.github.com/users/jtimon/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/bitcoin/bitcoin/labels/Mining","name":"Mining","color":"c7def8"},{"url":"https://api.github.com/repos/bitcoin/bitcoin/labels/TX%20fees%20and%20policy","name":"TX fees and policy","color":"5319e7"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":17,"created_at":"2015-01-03T15:50:04Z","updated_at":"2015-04-23T00:56:15Z","closed_at":"2015-04-23T00:56:15Z","pull_request":{"url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/5595","html_url":"https://github.com/bitcoin/bitcoin/pull/5595","diff_url":"https://github.com/bitcoin/bitcoin/pull/5595.diff","patch_url":"https://github.com/bitcoin/bitcoin/pull/5595.patch"},"body":"First steps for encapsulating the policy code.\r\nAn interface (abstract class) CPolicy and a concrete implementation CStandardPolicy are created.\r\n\"Users\" (people capable of modify and build Bitcoin core) can implement alternative policies and select them with the option -policy=<policy_name>. They can define new policy options and make their help messages be accesible to the users without having to touch init.cpp, only modifying policy.cpp is enough for all this. The help messages can also be accessed (per available policy) as a vector of string pairs to make it easier to implement a GUI to configure those options (although I don't plan to do that myself).\r\nAs more parts of the policy code move to policy.cpp, this encapsulation gets more useful.\r\n\r\nTo start using it. The function script/standard.o::IsStandard() is turned into a method: ApproveScript().\r\nMany more policy-related improvements can be cleanly proposed after this first steps are merged.\r\n\r\nOUTDATED:\r\nThis is an attempt to get a first commit for moving policy-related code together as proposed in #4943.\r\nThe main purpose of this PR is therefore discuss the commit \"Policy: Create CPolicy interface and CStandardPolicy implemention\" (https://github.com/jtimon/bitcoin/commit/572f12948285b14fcb2c2d1c9e2f51e749cc6cb6) which may change with suggestions.\r\nThe commit \"Policy: MOVEONLY: script/standard.o::IsStandard() -> CPolicy::ValidateScript()\" (https://github.com/jtimon/bitcoin/commit/9e99ebafc38718ca54730e764091a82a248a1a3c) acts as an example for adding a method to CPolicy. \r\nThe commit \"Policy: Refactor: Move datacarrier policy logic to policy.o\" (https://github.com/jtimon/bitcoin/commit/f141dd0b9b4059c2d54d0762d5dd0fe86976a18a) is an example of adding an attribute to CStandardPolicy without exposing it on CPolicy or exposing CStandardPolicy itself.\r\nAn example of a crazy custom policy that a user could implement for its local node can be found in https://github.com/jtimon/bitcoin/compare/policy_example\r\n\r\nThe commit \"Policy: Refactor: Move datacarrier policy logic to policy.o\" may be considered too risky and may be left for later to avoid delaying the first step. \r\nMaybe https://github.com/jtimon/bitcoin/commit/a2954632879076d3b9763001aca21bf768797e54 is not welcomed. It is only necessary if you want to make InitPolicyFromArgs() and CPolicy::InitFromArgs() param mapArgs const and don't want to duplicate code.\r\n\r\nI am very sorry for letting the ut acks rot."},"comment":{"url":"https://api.github.com/repos/bitcoin/bitcoin/issues/comments/95378188","html_url":"https://github.com/bitcoin/bitcoin/pull/5595#issuecomment-95378188","issue_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/5595","id":95378188,"user":{"login":"jtimon","id":1008458,"avatar_url":"https://avatars.githubusercontent.com/u/1008458?v=3","gravatar_id":"","url":"https://api.github.com/users/jtimon","html_url":"https://github.com/jtimon","followers_url":"https://api.github.com/users/jtimon/followers","following_url":"https://api.github.com/users/jtimon/following{/other_user}","gists_url":"https://api.github.com/users/jtimon/gists{/gist_id}","starred_url":"https://api.github.com/users/jtimon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jtimon/subscriptions","organizations_url":"https://api.github.com/users/jtimon/orgs","repos_url":"https://api.github.com/users/jtimon/repos","events_url":"https://api.github.com/users/jtimon/events{/privacy}","received_events_url":"https://api.github.com/users/jtimon/received_events","type":"User","site_admin":false},"created_at":"2015-04-23T00:56:14Z","updated_at":"2015-04-23T00:56:14Z","body":"Closing until #5696 is resolved"}}