Skip to content

Commit e8342b1

Browse files
committed
Pbft: implemented variable round time.
1 parent 57a2da4 commit e8342b1

File tree

5 files changed

+215
-141
lines changed

5 files changed

+215
-141
lines changed

core/block_crypt.cpp

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2240,6 +2240,7 @@ namespace beam
22402240
Magic.v2 = 2;
22412241

22422242
m_Pbft.m_Whitelist.m_NumRequired = 0;
2243+
m_Pbft.m_RoundUp_ms = 0;
22432244

22442245
// 1 eth == 10^18 wei
22452246
// 1 beam == 10^8 groth
@@ -2533,31 +2534,6 @@ namespace beam
25332534
// (addr == m_Addresses[iPos]);
25342535
}
25352536

2536-
uint64_t Rules::Pbft::T2S(uint64_t t_ms) const
2537-
{
2538-
assert(Consensus::Pbft == get_ParentObj().m_Consensus);
2539-
auto tSlot_ms = get_ParentObj().DA.Target_ms;
2540-
if (!tSlot_ms)
2541-
return 0; // ?!
2542-
2543-
return t_ms / tSlot_ms;
2544-
}
2545-
2546-
uint64_t Rules::Pbft::T2S_strict(uint64_t t_ms) const
2547-
{
2548-
auto iSlot = T2S(t_ms);
2549-
if (iSlot * get_ParentObj().DA.Target_ms != t_ms)
2550-
return 0; // inaccurate timestamp
2551-
2552-
return iSlot;
2553-
}
2554-
2555-
uint64_t Rules::Pbft::S2T(uint64_t iSlot) const
2556-
{
2557-
assert(Consensus::Pbft == get_ParentObj().m_Consensus);
2558-
return iSlot * get_ParentObj().DA.Target_ms; // don't care about overflow
2559-
}
2560-
25612537
void Rules::UpdateChecksum()
25622538
{
25632539
Exc::CheckpointTxt cp("Rules");
@@ -2623,8 +2599,9 @@ namespace beam
26232599
std::sort(vec.begin(), vec.end());
26242600

26252601
oracle
2626-
<< "pbft.2"
2602+
<< "pbft.3"
26272603
<< DA.Target_ms
2604+
<< x.m_RoundUp_ms
26282605
<< x.m_Whitelist.m_NumRequired
26292606
<< vec.size();
26302607

@@ -2788,6 +2765,7 @@ namespace beam
27882765
m_Consensus = Consensus::Pbft;
27892766
DA.Target_ms = nTarget_ms;
27902767
DA.Difficulty0.m_Packed = 0;
2768+
m_Pbft.m_RoundUp_ms = nTarget_ms / 4;
27912769

27922770
ZeroObject(Emission);
27932771
Maturity.Coinbase = 0;

core/block_crypt.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -490,9 +490,7 @@ namespace beam
490490

491491
} m_Whitelist;
492492

493-
uint64_t T2S(uint64_t t_ms) const;
494-
uint64_t T2S_strict(uint64_t t_ms) const; // returns 0 iff time is not a multiple of Target_ms
495-
uint64_t S2T(uint64_t iSlot) const;
493+
uint32_t m_RoundUp_ms; // how much longer each new round is supposed to be
496494

497495
IMPLEMENT_GET_PARENT_OBJ(Rules, m_Pbft)
498496
} m_Pbft;

0 commit comments

Comments
 (0)