~ubuntu-branches/debian/stretch/bitcoin/stretch

« back to all changes in this revision

Viewing changes to src/policy/fees.cpp

  • Committer: Package Import Robot
  • Author(s): Anthony Towns
  • Date: 2016-10-21 17:13:13 UTC
  • mfrom: (1.3.2)
  • Revision ID: package-import@ubuntu.com-20161021171313-7eu2ltpbk0xag3q1
Tags: 0.13.0-0.1
* Non-maintainer upload.
* New upstream release.
* Allow compilation with gcc/g++ 6. (Closes: Bug#835963)
* Additional fixes for openssl 1.1 compatibility. (See Bug#828248)
* Check if -latomic is needed (it is on mips*).
* Remove reproducible build patch, since leveldb build system is
  no longer used in 0.13. (See Bug#791834)
* Update description since the blockchain is much more than "several GB"
  now. (Closes: Bug#835809)

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 
9
9
#include "amount.h"
10
10
#include "primitives/transaction.h"
 
11
#include "random.h"
11
12
#include "streams.h"
12
13
#include "txmempool.h"
13
14
#include "util.h"
87
88
    int maxbucketindex = buckets.size() - 1;
88
89
 
89
90
    // requireGreater means we are looking for the lowest fee/priority such that all higher
90
 
    // values pass, so we start at maxbucketindex (highest fee) and look at succesively
 
91
    // values pass, so we start at maxbucketindex (highest fee) and look at successively
91
92
    // smaller buckets until we reach failure.  Otherwise, we are looking for the highest
92
93
    // fee/priority such that all lower values fail, and we go in the opposite direction.
93
94
    unsigned int startbucket = requireGreater ? maxbucketindex : 0;
580
581
    priStats.Read(filein);
581
582
    nBestSeenHeight = nFileBestSeenHeight;
582
583
}
 
584
 
 
585
FeeFilterRounder::FeeFilterRounder(const CFeeRate& minIncrementalFee)
 
586
{
 
587
    CAmount minFeeLimit = minIncrementalFee.GetFeePerK() / 2;
 
588
    feeset.insert(0);
 
589
    for (double bucketBoundary = minFeeLimit; bucketBoundary <= MAX_FEERATE; bucketBoundary *= FEE_SPACING) {
 
590
        feeset.insert(bucketBoundary);
 
591
    }
 
592
}
 
593
 
 
594
CAmount FeeFilterRounder::round(CAmount currentMinFee)
 
595
{
 
596
    std::set<double>::iterator it = feeset.lower_bound(currentMinFee);
 
597
    if ((it != feeset.begin() && insecure_rand() % 3 != 0) || it == feeset.end()) {
 
598
        it--;
 
599
    }
 
600
    return *it;
 
601
}