Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdint.h>
- uint64_t MaxBlockSize(uint64_t nBlockTimestamp, uint64_t nSizeForkActivationTime);
- /** Maximum block size parameters */
- uint32_t nMaxSizePreFork = 1000*1000;
- uint64_t nEarliestSizeForkTime = 1452470400;
- uint32_t nSizeDoubleEpoch = 60*60*24*365*2;
- uint64_t nMaxSizeBase = 8*1000*1000;
- uint8_t nMaxSizeDoublings = 10;
- uint64_t nSizeForkGracePeriod = 60*60*24;
- int main() {
- uint64_t blockTime=nEarliestSizeForkTime;
- printf("blockTime,maxSize\n");
- for(int i=1;i<64;i++) {
- MaxBlockSize( blockTime, nEarliestSizeForkTime );
- printf( "%llu,%llu\n", blockTime, MaxBlockSize( blockTime, 1438387200 ) );
- blockTime=blockTime+2592000; //add 30 days
- }
- }
- uint64_t MaxBlockSize(uint64_t nBlockTimestamp, uint64_t nSizeForkActivationTime) {
- if (nBlockTimestamp < nEarliestSizeForkTime || nBlockTimestamp < nSizeForkActivationTime)
- return nMaxSizePreFork;
- if (nBlockTimestamp >= nEarliestSizeForkTime + nSizeDoubleEpoch * nMaxSizeDoublings)
- return nMaxSizeBase << nMaxSizeDoublings;
- // Piecewise-linear-between-doublings growth. Calculated based on a fixed
- // timestamp and not the activation time so the maximum size is
- // predictable, and so the activation time can be completely removed in
- // a future version of this code after the fork is complete.
- uint64_t timeDelta = nBlockTimestamp - nEarliestSizeForkTime;
- uint64_t doublings = timeDelta / nSizeDoubleEpoch;
- uint64_t remain = timeDelta % nSizeDoubleEpoch;
- uint64_t interpolate = (nMaxSizeBase << doublings) * remain / nSizeDoubleEpoch;
- uint64_t nMaxSize = (nMaxSizeBase << doublings) + interpolate;
- // printf("%llu,%llu,%llu,%llu,%llu\n",timeDelta,doublings,remain,interpolate,nMaxSize);
- return nMaxSize;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement