Skip to content

Commit

Permalink
Merge pull request #133 from nspcc-dev/expose-preblock
Browse files Browse the repository at this point in the history
contest: expose PreBlock instead of PreHeader
  • Loading branch information
roman-khimov authored Oct 30, 2024
2 parents ba32988 + abb011f commit 82ad778
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ New features:

Behaviour changes:
* adjust behaviour of ProcessPreBlock callback (#129)
* (*DBFT).Header() and (*DBFT).PreHeader() are moved to (*Context) receiver (#133)

Improvements:
* minimum required Go version is 1.22 (#122, #126)
Expand All @@ -16,6 +17,7 @@ Bugs fixed:
* context-bound PreBlock and PreHeader are not reset properly (#127)
* PreHeader is constructed instead of PreBlock to create PreCommit message (#128)
* enable anti-MEV extension with respect to the current block index (#132)
* (*Context).PreBlock() method returns PreHeader instead of PreBlock (#133)

## [0.3.0] (01 August 2024)

Expand Down
17 changes: 16 additions & 1 deletion context.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,23 @@ func (c *Context[H]) MoreThanFNodesCommittedOrLost() bool {
return c.CountCommitted()+c.CountFailed() > c.F()
}

// Header returns current header from context. May be nil in case if no
// header is constructed yet. Do not change the resulting header.
func (c *Context[H]) Header() Block[H] {
return c.header
}

// PreHeader returns current preHeader from context. May be nil in case if no
// preHeader is constructed yet. Do not change the resulting preHeader.
func (c *Context[H]) PreHeader() PreBlock[H] {
return c.preHeader
}

// PreBlock returns current PreBlock from context. May be nil in case if no
// PreBlock is constructed yet (even if PreHeader is already constructed).
// External changes in the PreBlock will be seen by dBFT.
func (c *Context[H]) PreBlock() PreBlock[H] {
return c.preHeader // without transactions
return c.preBlock
}

func (c *Context[H]) reset(view byte, ts uint64) {
Expand Down
12 changes: 0 additions & 12 deletions dbft.go
Original file line number Diff line number Diff line change
Expand Up @@ -703,15 +703,3 @@ func (d *DBFT[H]) extendTimer(count int) {
d.Timer.Extend(time.Duration(count) * d.SecondsPerBlock / time.Duration(d.M()))
}
}

// Header returns current header from context. May be nil in case if no
// header is constructed yet. Do not change the resulting header.
func (d *DBFT[H]) Header() Block[H] {
return d.header
}

// PreHeader returns current preHeader from context. May be nil in case if no
// preHeader is constructed yet. Do not change the resulting preHeader.
func (d *DBFT[H]) PreHeader() PreBlock[H] {
return d.preHeader
}

0 comments on commit 82ad778

Please sign in to comment.