CBlockIndexWorkComparator 클래스

Words
27
Reading
1 min
Listen
Play
8y


블록타임 10분인 경우 누적분포도

CBlockIndexWorkComparator 는 블록을 비교하여 결과를 false, true로 반환한다. pa,pb 블록에대해 순서대로 pb가 totalwork가 크거나, 같은경우 수신시간이 늦은경우 true이다. 반대인경우 false이고 서로 같으면 false이다

namespace  {
     struct CBlockIndexWorkComparator
     {
         bool operator()(const CBlockIndex *pa, const CBlockIndex *pb) const {
             // First sort by most total work, ...
             if (pa->nChainWork > pb->nChainWork) return false;
             if (pa->nChainWork < pb->nChainWork) return true;
 
             // ... then by earliest time received, ...
             if (pa->nSequenceId < pb->nSequenceId) return false;
             if (pa->nSequenceId > pb->nSequenceId) return true;
 
             // Use pointer address as tie breaker (should only happen with blocks
             // loaded from disk, as those all have id 0).
             if (pa < pb) return false;
             if (pa > pb) return true;
 
             // Identical blocks.
             return false;
         }
     };
 } // anon namespace