Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ New features:

Behaviour changes:
* transactions management refactoring implied library API changes (#164)
* add a separate `DBFT` generic parameter for transaction slice type
specificatoin (#165)

Improvements:
* minimum required Go version is 1.26 (#144, #156, #162)
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ in `config.go`.
2. `dbft` package contains `PrivateKey`/`PublicKey` interfaces which permits usage of one's own
cryptography for signing blocks on `Commit` stage. Refer to `identity.go` for `PrivateKey`/`PublicKey`
description. No default implementation is provided.
3. `dbft` package contains `Hash` interface which permits usage of one's own
hash implementation without additional overhead on conversions. Instantiate dBFT with
custom hash implementation that matches requirements specified in the corresponding
documentation. Refer to `identity.go` for `Hash` description. No default implementation is
provided.
3. `dbft` package contains `Hash` and `Transaction` interfaces which permits usage of one's own
hash and transaction implementation without additional overhead on conversions. Instantiate dBFT with
custom hash and transaction implementation that matches requirements specified in the corresponding
documentation. Refer to `identity.go` for `Hash` description. Refer to `transaction.go` for `Transaction`
description. No default implementation is provided neither for `Hash` nor for `Transaction`.
4. `dbft` package contains `Block` and `Transaction` abstractions located at the `block.go` and
`transaction.go` files. Every block must be able to be signed and verified as well as implement getters
for main fields. `Transaction` is an entity which can be hashed. Two entities having
Expand Down
6 changes: 3 additions & 3 deletions block.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package dbft

// Block is a generic interface for a block used by dbft.
type Block[H Hash] interface {
type Block[H Hash, Tx Transaction[H]] interface {
// Hash returns block hash.
Hash() H
// PrevHash returns previous block hash.
Expand All @@ -19,12 +19,12 @@ type Block[H Hash] interface {
Verify(key PublicKey, sign []byte) error

// Transactions returns block's transaction list.
Transactions() []Transaction[H]
Transactions() []Tx
// SetTransactions sets block's transaction list. For anti-MEV extension
// transactions provided via this call are taken directly from PreBlock level
// and thus, may be out-of-date. Thus, with anti-MEV extension enabled it's
// suggested to use this method as a Block finalizer since it will be called
// right before the block approval. Do not rely on this with anti-MEV extension
// disabled.
SetTransactions([]Transaction[H])
SetTransactions([]Tx)
}
8 changes: 4 additions & 4 deletions check.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"go.uber.org/zap"
)

func (d *DBFT[H]) checkPrepare() {
func (d *DBFT[H, Tx]) checkPrepare() {
if d.lastBlockIndex != d.BlockIndex || d.lastBlockView != d.ViewNumber {
// Notice that lastBlockTimestamp is left unchanged because
// this must be the value from the last header.
Expand Down Expand Up @@ -49,7 +49,7 @@ func (d *DBFT[H]) checkPrepare() {
}
}

func (d *DBFT[H]) checkPreCommit() {
func (d *DBFT[H, Tx]) checkPreCommit() {
if !d.hasAllTransactions() {
d.Logger.Debug("check preCommit: some transactions are missing", zap.Any("hashes", d.MissingTransactions))
return
Expand Down Expand Up @@ -103,7 +103,7 @@ func (d *DBFT[H]) checkPreCommit() {
}
}

func (d *DBFT[H]) checkCommit() {
func (d *DBFT[H, Tx]) checkCommit() {
if !d.hasAllTransactions() {
d.Logger.Debug("check commit: some transactions are missing", zap.Any("hashes", d.MissingTransactions))
return
Expand Down Expand Up @@ -152,7 +152,7 @@ func (d *DBFT[H]) checkCommit() {
// new height.
}

func (d *DBFT[H]) checkChangeView(view byte) {
func (d *DBFT[H, Tx]) checkChangeView(view byte) {
if d.ViewNumber >= view {
return
}
Expand Down
Loading
Loading