Skip to content

Commit

Permalink
*: move PreHeader() and Header() getters to Context
Browse files Browse the repository at this point in the history
These fields are a part of dBFT context, they should be accessible via
those methods that expose Context to the user.

Signed-off-by: Anna Shaleva <[email protected]>
  • Loading branch information
AnnaShaleva committed Oct 30, 2024
1 parent f25e7ce commit 5d6954c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 12 additions & 0 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,18 @@ 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.
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 5d6954c

Please sign in to comment.