Skip to content

Commit 7e15b1f

Browse files
authored
Merge pull request #104 from nspcc-dev/reduce-apis
Remove unused dBFT APIs
2 parents 1db32ec + d504ad8 commit 7e15b1f

36 files changed

+541
-568
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Behaviour changes:
1313
* rename `InitializeConsensus` dBFT method to `Reset` (#95)
1414
* drop outdated dBFT `Service` interface (#95)
1515
* move all default implementations to `internal` package (#97)
16+
* remove unused APIs of dBFT and payload interfaces (#104)
1617

1718
Improvements:
1819
* add MIT License (#78, #79)

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,19 @@ in `config.go`.
1414
2. `dbft` package contains `PrivateKey`/`PublicKey` interfaces which permits usage of one's own
1515
cryptography for signing blocks on `Commit` stage. Refer to `identity.go` for `PrivateKey`/`PublicKey`
1616
description. No default implementation is provided.
17-
3. `dbft` package contains `Hash`/`Address` interfaces which permits usage of one's own
18-
hash/address implementation without additional overhead on conversions. Instantiate dBFT with
19-
custom hash/address implementation that matches requirements specified in the corresponding
20-
documentation. Refer to `identity.go` for `Hash`/`Address` description. No default implementation is
17+
3. `dbft` package contains `Hash` interface which permits usage of one's own
18+
hash implementation without additional overhead on conversions. Instantiate dBFT with
19+
custom hash implementation that matches requirements specified in the corresponding
20+
documentation. Refer to `identity.go` for `Hash` description. No default implementation is
2121
provided.
2222
4. `dbft` package contains `Block` and `Transaction` abstractions located at the `block.go` and
23-
`transaction.go` files. Every block must be able to be signed and verified as well as implement setters
24-
and getters for main fields. `Transaction` is an entity which can be hashed. Two entities having
23+
`transaction.go` files. Every block must be able to be signed and verified as well as implement getters
24+
for main fields. `Transaction` is an entity which can be hashed. Two entities having
2525
equal hashes are considered equal. No default implementation is provided.
2626
5. `dbft` contains generic interfaces for payloads. No default implementation is provided.
27-
6. `timer` contains default time provider. It should make it easier to write tests
28-
concerning dBFT's time depending behaviour.
27+
6. `dbft` contains generic interfaces for time-related operations (`Timer` and `HV`). `timer` package contains
28+
default time and height-view providers, it contains minimal required timer functionality and may safely be used in
29+
production code. It should make it easier to write tests concerning dBFT's time depending behaviour.
2930
7. `internal` contains an example of custom identity types and payloads implementation used to implement
3031
an example of dBFT's usage with 6-node consensus. Refer to `internal` subpackages for type-specific dBFT
3132
implementation and tests. Refer to `internal/simulation` for an example of dBFT library usage.

block.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,15 @@
11
package dbft
22

33
// Block is a generic interface for a block used by dbft.
4-
type Block[H Hash, A Address] interface {
4+
type Block[H Hash] interface {
55
// Hash returns block hash.
66
Hash() H
7-
8-
Version() uint32
97
// PrevHash returns previous block hash.
108
PrevHash() H
119
// MerkleRoot returns a merkle root of the transaction hashes.
1210
MerkleRoot() H
13-
// Timestamp returns block's proposal timestamp.
14-
Timestamp() uint64
1511
// Index returns block index.
1612
Index() uint32
17-
// ConsensusData is a random nonce.
18-
ConsensusData() uint64
19-
// NextConsensus returns hash of the validators of the next block.
20-
NextConsensus() A
2113

2214
// Signature returns block's signature.
2315
Signature() []byte

change_view.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ type ChangeView interface {
55
// NewViewNumber returns proposed view number.
66
NewViewNumber() byte
77

8-
// Timestamp returns message's timestamp.
9-
Timestamp() uint64
10-
118
// Reason returns change view reason.
129
Reason() ChangeViewReason
1310
}

check.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"go.uber.org/zap"
55
)
66

7-
func (d *DBFT[H, A]) checkPrepare() {
7+
func (d *DBFT[H]) checkPrepare() {
88
if !d.hasAllTransactions() {
99
d.Logger.Debug("check prepare: some transactions are missing", zap.Any("hashes", d.MissingTransactions))
1010
return
@@ -36,7 +36,7 @@ func (d *DBFT[H, A]) checkPrepare() {
3636
}
3737
}
3838

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

80-
func (d *DBFT[H, A]) checkChangeView(view byte) {
80+
func (d *DBFT[H]) checkChangeView(view byte) {
8181
if d.ViewNumber >= view {
8282
return
8383
}

0 commit comments

Comments
 (0)