Skip to content

Commit 5187e61

Browse files
authored
Merge pull request #154 from nspcc-dev/fix-linter-errors
2 parents 3bbcc12 + c5ad6fd commit 5187e61

5 files changed

Lines changed: 26 additions & 26 deletions

File tree

dbft.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ func (d *DBFT[H]) onTimeout(height uint32, view byte, force bool) {
233233
d.unsubscribeFromTransactions()
234234
return
235235
}
236-
if !d.txSubscriptionOn && len(d.Config.GetVerified()) == 0 {
236+
if !d.txSubscriptionOn && len(d.GetVerified()) == 0 {
237237
d.subscribeForTransactions()
238238
delay := d.maxTimePerBlock<<1 - d.timePerBlock<<1
239239
d.changeTimer(delay)
@@ -319,7 +319,7 @@ func (d *DBFT[H]) OnReceive(msg ConsensusPayload[H]) {
319319
func (d *DBFT[H]) onPrepareRequest(msg ConsensusPayload[H]) {
320320
// ignore prepareRequest if we had already received it or
321321
// are in process of changing view
322-
if d.RequestSentOrReceived() { //|| (d.ViewChanging() && !d.MoreThanFNodesCommittedOrLost()) {
322+
if d.RequestSentOrReceived() { // || (d.ViewChanging() && !d.MoreThanFNodesCommittedOrLost()) {
323323
d.Logger.Debug("ignoring PrepareRequest",
324324
zap.Bool("sor", d.RequestSentOrReceived()),
325325
zap.Bool("viewChanging", d.ViewChanging()),
@@ -390,13 +390,13 @@ func (d *DBFT[H]) processMissingTx() {
390390
func (d *DBFT[H]) createAndCheckBlock() bool {
391391
var blockOK bool
392392
if d.isAntiMEVExtensionEnabled() {
393-
b := d.Context.CreatePreBlock()
393+
b := d.CreatePreBlock()
394394
blockOK = d.VerifyPreBlock(b)
395395
if !blockOK {
396396
d.Logger.Warn("proposed preBlock fails verification")
397397
}
398398
} else {
399-
b := d.Context.CreateBlock()
399+
b := d.CreateBlock()
400400
blockOK = d.VerifyBlock(b)
401401
if !blockOK {
402402
d.Logger.Warn("proposed block fails verification")
@@ -705,7 +705,7 @@ func (d *DBFT[H]) onRecoveryMessage(msg ConsensusPayload[H]) {
705705
}
706706
}
707707

708-
if msg.ViewNumber() == d.ViewNumber && !(d.ViewChanging() && !d.MoreThanFNodesCommittedOrLost()) && !d.CommitSent() && (!d.isAntiMEVExtensionEnabled() || !d.PreCommitSent()) {
708+
if msg.ViewNumber() == d.ViewNumber && (!d.ViewChanging() || d.MoreThanFNodesCommittedOrLost()) && !d.CommitSent() && (!d.isAntiMEVExtensionEnabled() || !d.PreCommitSent()) {
709709
if !d.RequestSentOrReceived() {
710710
prepReq := recovery.GetPrepareRequest(msg, d.Validators, uint16(d.PrimaryIndex))
711711
if prepReq != nil {

dbft_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -590,13 +590,13 @@ func TestDBFT_Invalid(t *testing.T) {
590590
d, err := dbft.New(opts...)
591591
require.NoError(t, err)
592592
require.NotNil(t, d)
593-
require.NotNil(t, d.Config.RequestTx)
594-
require.NotNil(t, d.Config.GetTx)
595-
require.NotNil(t, d.Config.GetVerified)
596-
require.NotNil(t, d.Config.VerifyBlock)
597-
require.NotNil(t, d.Config.Broadcast)
598-
require.NotNil(t, d.Config.ProcessBlock)
599-
require.NotNil(t, d.Config.GetBlock)
593+
require.NotNil(t, d.RequestTx)
594+
require.NotNil(t, d.GetTx)
595+
require.NotNil(t, d.GetVerified)
596+
require.NotNil(t, d.VerifyBlock)
597+
require.NotNil(t, d.Broadcast)
598+
require.NotNil(t, d.ProcessBlock)
599+
require.NotNil(t, d.GetBlock)
600600
require.NotNil(t, d.Config.WatchOnly)
601601
})
602602
}

internal/consensus/amev_preBlock.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,25 @@ var _ dbft.PreBlock[crypto.Uint256] = new(preBlock)
2424
// NewPreBlock returns new preBlock.
2525
func NewPreBlock(timestamp uint64, index uint32, prevHash crypto.Uint256, nonce uint64, txHashes []crypto.Uint256) dbft.PreBlock[crypto.Uint256] {
2626
pre := new(preBlock)
27-
pre.base.Timestamp = uint32(timestamp / 1000000000)
28-
pre.base.Index = index
27+
pre.Timestamp = uint32(timestamp / 1000000000)
28+
pre.Index = index
2929

3030
// NextConsensus and Version information is not provided by dBFT context,
3131
// these are implementation-specific fields, and thus, should be managed outside the
3232
// dBFT library. For simulation simplicity, let's assume that these fields are filled
3333
// by every CN separately and is not verified.
34-
pre.base.NextConsensus = crypto.Uint160{1, 2, 3}
35-
pre.base.Version = 0
34+
pre.NextConsensus = crypto.Uint160{1, 2, 3}
35+
pre.Version = 0
3636

37-
pre.base.PrevHash = prevHash
38-
pre.base.ConsensusData = nonce
37+
pre.PrevHash = prevHash
38+
pre.ConsensusData = nonce
3939

4040
// Canary default value.
4141
pre.data = 0xff
4242

4343
if len(txHashes) != 0 {
4444
mt := merkle.NewMerkleTree(txHashes...)
45-
pre.base.MerkleRoot = mt.Root().Hash
45+
pre.MerkleRoot = mt.Root().Hash
4646
}
4747
return pre
4848
}
@@ -56,15 +56,15 @@ func (pre *preBlock) Data() []byte {
5656
func (pre *preBlock) SetData(_ dbft.PrivateKey) error {
5757
// Just an artificial rule for data construction, it can be anything, and in Neo X
5858
// it will be decrypted transactions fragments.
59-
pre.data = pre.base.Index
59+
pre.data = pre.Index
6060
return nil
6161
}
6262

6363
func (pre *preBlock) Verify(_ dbft.PublicKey, data []byte) error {
6464
if len(data) != 4 {
6565
return errors.New("invalid data len")
6666
}
67-
if binary.BigEndian.Uint32(data) != pre.base.Index { // Just an artificial verification rule, and for NeoX it should be decrypted transactions fragments verification.
67+
if binary.BigEndian.Uint32(data) != pre.Index { // Just an artificial verification rule, and for NeoX it should be decrypted transactions fragments verification.
6868
return errors.New("invalid data")
6969
}
7070
return nil

internal/consensus/block.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,18 @@ func (b *neoBlock) SetTransactions(txx []dbft.Transaction[crypto.Uint256]) {
6868
// NewBlock returns new block.
6969
func NewBlock(timestamp uint64, index uint32, prevHash crypto.Uint256, nonce uint64, txHashes []crypto.Uint256) dbft.Block[crypto.Uint256] {
7070
block := new(neoBlock)
71-
block.base.Timestamp = uint32(timestamp / 1000000000)
71+
block.Timestamp = uint32(timestamp / 1000000000)
7272
block.base.Index = index
7373

7474
// NextConsensus and Version information is not provided by dBFT context,
7575
// these are implementation-specific fields, and thus, should be managed outside the
7676
// dBFT library. For simulation simplicity, let's assume that these fields are filled
7777
// by every CN separately and is not verified.
78-
block.base.NextConsensus = crypto.Uint160{1, 2, 3}
79-
block.base.Version = 0
78+
block.NextConsensus = crypto.Uint160{1, 2, 3}
79+
block.Version = 0
8080

8181
block.base.PrevHash = prevHash
82-
block.base.ConsensusData = nonce
82+
block.ConsensusData = nonce
8383

8484
if len(txHashes) != 0 {
8585
mt := merkle.NewMerkleTree(txHashes...)

send.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ func (d *DBFT[H]) sendRecoveryRequest() {
190190
d.processMissingTx()
191191
}
192192
req := d.NewRecoveryRequest(uint64(d.Timer.Now().UnixNano()))
193-
d.broadcast(d.Config.NewConsensusPayload(&d.Context, RecoveryRequestType, req))
193+
d.broadcast(d.NewConsensusPayload(&d.Context, RecoveryRequestType, req))
194194
}
195195

196196
func (c *Context[H]) makeRecoveryMessage() ConsensusPayload[H] {

0 commit comments

Comments
 (0)