Skip to content

Commit

Permalink
Merge pull request #104 from nspcc-dev/reduce-apis
Browse files Browse the repository at this point in the history
Remove unused dBFT APIs
  • Loading branch information
roman-khimov committed Mar 8, 2024
2 parents 1db32ec + d504ad8 commit 7e15b1f
Show file tree
Hide file tree
Showing 36 changed files with 541 additions and 568 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Behaviour changes:
* rename `InitializeConsensus` dBFT method to `Reset` (#95)
* drop outdated dBFT `Service` interface (#95)
* move all default implementations to `internal` package (#97)
* remove unused APIs of dBFT and payload interfaces (#104)

Improvements:
* add MIT License (#78, #79)
Expand Down
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,19 @@ 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`/`Address` interfaces which permits usage of one's own
hash/address implementation without additional overhead on conversions. Instantiate dBFT with
custom hash/address implementation that matches requirements specified in the corresponding
documentation. Refer to `identity.go` for `Hash`/`Address` description. No default implementation is
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.
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 setters
and getters for main fields. `Transaction` is an entity which can be hashed. Two entities having
`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
equal hashes are considered equal. No default implementation is provided.
5. `dbft` contains generic interfaces for payloads. No default implementation is provided.
6. `timer` contains default time provider. It should make it easier to write tests
concerning dBFT's time depending behaviour.
6. `dbft` contains generic interfaces for time-related operations (`Timer` and `HV`). `timer` package contains
default time and height-view providers, it contains minimal required timer functionality and may safely be used in
production code. It should make it easier to write tests concerning dBFT's time depending behaviour.
7. `internal` contains an example of custom identity types and payloads implementation used to implement
an example of dBFT's usage with 6-node consensus. Refer to `internal` subpackages for type-specific dBFT
implementation and tests. Refer to `internal/simulation` for an example of dBFT library usage.
Expand Down
10 changes: 1 addition & 9 deletions block.go
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
package dbft

// Block is a generic interface for a block used by dbft.
type Block[H Hash, A Address] interface {
type Block[H Hash] interface {
// Hash returns block hash.
Hash() H

Version() uint32
// PrevHash returns previous block hash.
PrevHash() H
// MerkleRoot returns a merkle root of the transaction hashes.
MerkleRoot() H
// Timestamp returns block's proposal timestamp.
Timestamp() uint64
// Index returns block index.
Index() uint32
// ConsensusData is a random nonce.
ConsensusData() uint64
// NextConsensus returns hash of the validators of the next block.
NextConsensus() A

// Signature returns block's signature.
Signature() []byte
Expand Down
3 changes: 0 additions & 3 deletions change_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ type ChangeView interface {
// NewViewNumber returns proposed view number.
NewViewNumber() byte

// Timestamp returns message's timestamp.
Timestamp() uint64

// Reason returns change view reason.
Reason() ChangeViewReason
}
6 changes: 3 additions & 3 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, A]) checkPrepare() {
func (d *DBFT[H]) checkPrepare() {
if !d.hasAllTransactions() {
d.Logger.Debug("check prepare: some transactions are missing", zap.Any("hashes", d.MissingTransactions))
return
Expand Down Expand Up @@ -36,7 +36,7 @@ func (d *DBFT[H, A]) checkPrepare() {
}
}

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

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

0 comments on commit 7e15b1f

Please sign in to comment.