MCPcopy Create free account
hub / github.com/WaykiChain/WaykiChain / UpdateGlobalFinBlock

Method UpdateGlobalFinBlock

src/miner/pbftmanager.cpp:86–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84}
85
86bool CPBFTMan::UpdateGlobalFinBlock(const uint32_t height) {
87 {
88 LOCK(cs_finblock);
89 CBlockIndex* oldGlobalFinblock = GetGlobalFinIndex();
90 CBlockIndex* localFinblock = GetLocalFinIndex();
91
92 if(localFinblock== nullptr ||height > (uint32_t)localFinblock->height)
93 return false;
94 if(oldGlobalFinblock != nullptr && (uint32_t)oldGlobalFinblock->height >= height)
95 return false;
96
97 if(oldGlobalFinblock != nullptr ){
98 CBlockIndex* chainBlock = chainActive[oldGlobalFinblock->height];
99 if(chainBlock != nullptr && chainBlock->GetBlockHash() != oldGlobalFinblock->GetBlockHash()){
100 return ERRORMSG("Global finality block changed");
101 }
102 }
103
104 CBlockIndex* pTemp = chainActive[height];
105 if(pTemp== nullptr)
106 return false;
107 globalFinIndex = pTemp;
108 globalFinHash = pTemp->GetBlockHash();
109 pCdMan->pBlockCache->WriteGlobalFinBlock(pTemp->height, pTemp->GetBlockHash());
110 return true;
111 }
112
113}
114
115bool CPBFTMan::UpdateLocalFinBlock(const CBlockIndex* pIndex){
116

Callers 2

AcceptBlockFunction · 0.80

Calls 7

GetFinalBlockMinerCountFunction · 0.85
WriteGlobalFinBlockMethod · 0.80
GetBlockHashMethod · 0.45
sizeMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected