{"action":"created","issue":{"url":"https://api.github.com/repos/bitcoin/bitcoin/issues/5863","labels_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/5863/labels{/name}","comments_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/5863/comments","events_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/5863/events","html_url":"https://github.com/bitcoin/bitcoin/pull/5863","id":60169492,"number":5863,"title":"Add autoprune functionality","user":{"login":"sdaftuar","id":7463573,"avatar_url":"https://avatars.githubusercontent.com/u/7463573?v=3","gravatar_id":"","url":"https://api.github.com/users/sdaftuar","html_url":"https://github.com/sdaftuar","followers_url":"https://api.github.com/users/sdaftuar/followers","following_url":"https://api.github.com/users/sdaftuar/following{/other_user}","gists_url":"https://api.github.com/users/sdaftuar/gists{/gist_id}","starred_url":"https://api.github.com/users/sdaftuar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sdaftuar/subscriptions","organizations_url":"https://api.github.com/users/sdaftuar/orgs","repos_url":"https://api.github.com/users/sdaftuar/repos","events_url":"https://api.github.com/users/sdaftuar/events{/privacy}","received_events_url":"https://api.github.com/users/sdaftuar/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/bitcoin/bitcoin/labels/Feature","name":"Feature","color":"7cf575"}],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/bitcoin/bitcoin/milestones/18","html_url":"https://github.com/bitcoin/bitcoin/milestones/0.11.0","labels_url":"https://api.github.com/repos/bitcoin/bitcoin/milestones/18/labels","id":818033,"number":18,"title":"0.11.0","description":"","creator":{"login":"laanwj","id":126646,"avatar_url":"https://avatars.githubusercontent.com/u/126646?v=3","gravatar_id":"","url":"https://api.github.com/users/laanwj","html_url":"https://github.com/laanwj","followers_url":"https://api.github.com/users/laanwj/followers","following_url":"https://api.github.com/users/laanwj/following{/other_user}","gists_url":"https://api.github.com/users/laanwj/gists{/gist_id}","starred_url":"https://api.github.com/users/laanwj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/laanwj/subscriptions","organizations_url":"https://api.github.com/users/laanwj/orgs","repos_url":"https://api.github.com/users/laanwj/repos","events_url":"https://api.github.com/users/laanwj/events{/privacy}","received_events_url":"https://api.github.com/users/laanwj/received_events","type":"User","site_admin":false},"open_issues":6,"closed_issues":13,"state":"open","created_at":"2014-10-08T08:27:24Z","updated_at":"2015-05-12T14:37:29Z","due_on":null,"closed_at":null},"comments":55,"created_at":"2015-03-06T22:40:58Z","updated_at":"2015-05-12T16:38:14Z","closed_at":"2015-04-24T08:37:00Z","pull_request":{"url":"https://api.github.com/repos/bitcoin/bitcoin/pulls/5863","html_url":"https://github.com/bitcoin/bitcoin/pull/5863","diff_url":"https://github.com/bitcoin/bitcoin/pull/5863.diff","patch_url":"https://github.com/bitcoin/bitcoin/pull/5863.patch"},"body":"Continuing the work of @rdponticelli, this is an implementation of the autoprune functionality (see #4701).  Thanks to @rdponticelli for doing a lot of prior work on this topic; we used his work and the discussion of it as our starting point (though we found it easier to base this pull off of master).  @mrbandrews, @morcos, @ajweiss, and @sdaftuar collaborated on this pull.  \r\n\r\nTo summarize autoprune: this adds a -prune=N option to bitcoind, which if set to N>0 will enable autoprune.  When autopruning is enabled, block and undo files will be deleted to try to keep total space used by those files to below the prune target (N, in MB) specified by the user, subject to some constraints:\r\n\r\n- The last 288 blocks on the main chain are always kept (MIN_BLOCKS_TO_KEEP),\r\n- N must be at least 550MB (chosen as a value for the target that could reasonably be met, with some assumptions about block sizes, orphan rates, etc; see comment in main.h),\r\n- No blocks are pruned until chainActive is at least 100,000 blocks long (on mainnet; defined separately for mainnet, testnet, and regtest in chainparams as nAutopruneAfterHeight).\r\n\r\nWe’ve attempted to address the comments raised in the prior conversations; here are a few things worth noting:\r\n\r\n1.  Handling reorgs greater than the data stored on disk is not yet implemented.  Currently, bitcoind will exit with a message indicating that it failed to read the block on disk -- suggestions for a better error message are welcome.\r\n2.  We’ve disabled block relay (with a check to see if we’re NODE_NETWORK or not).  In the future when we have worked out the service bit to use for an autopruned node and the behavior for block requests, we can re-enable this appropriately.  (This differs from the behavior of #4701 .)\r\n3.  PruneOneBlockFile currently iterates mapBlockIndex each time to determine which entries to update; we can optimize this by maintaining a reverse lookup table so that the blocks in each blockfile are known.  \r\n4.  One open question is what to do if we’ve pruned before, and then are running a -reindex: what do we do with the leftover files?  In this case, the first N files will have been deleted by the pruning code, which won’t be processed in the reindex loop, but later we may try overwriting the remaining files in place.  Would it be better to, say, delete the files preemptively to prevent potential file corruption? \r\n5.  RPC/REST interfaces currently do not distinguish between unknown blocks/tx and pruned blocks/tx.  It's unclear if a specific error should be returned, or perhaps the block/tx query interfaces be disabled for pruned nodes.\r\n6. Tests and a test plan will be forthcoming.\r\n\r\n(Though this pull still needs more work to address some of the above items, we thought we'd open it now to keep review momentum on this feature moving...)"},"comment":{"url":"https://api.github.com/repos/bitcoin/bitcoin/issues/comments/101343245","html_url":"https://github.com/bitcoin/bitcoin/pull/5863#issuecomment-101343245","issue_url":"https://api.github.com/repos/bitcoin/bitcoin/issues/5863","id":101343245,"user":{"login":"dacox","id":3887682,"avatar_url":"https://avatars.githubusercontent.com/u/3887682?v=3","gravatar_id":"","url":"https://api.github.com/users/dacox","html_url":"https://github.com/dacox","followers_url":"https://api.github.com/users/dacox/followers","following_url":"https://api.github.com/users/dacox/following{/other_user}","gists_url":"https://api.github.com/users/dacox/gists{/gist_id}","starred_url":"https://api.github.com/users/dacox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dacox/subscriptions","organizations_url":"https://api.github.com/users/dacox/orgs","repos_url":"https://api.github.com/users/dacox/repos","events_url":"https://api.github.com/users/dacox/events{/privacy}","received_events_url":"https://api.github.com/users/dacox/received_events","type":"User","site_admin":false},"created_at":"2015-05-12T16:38:14Z","updated_at":"2015-05-12T16:38:14Z","body":"According to `bitcoind -help` it's Bitcoin Core Daemon version v0.10.1.0-gd8ac901\r\n\r\nI grabbed it from the PPA, and I saw that this PR was merged in before the release was tagged. \r\n\r\nHowever, I do not see a reference to -prune in the help output"}}