Merge pull request #1841 from nspcc-dev/conesnsus/fix-preparerequest
consensus: remove nonce from PrepareRequest
This commit is contained in:
commit
7c50bbc649
4 changed files with 2 additions and 12 deletions
|
@ -201,7 +201,6 @@ func randomPrepareRequest(t *testing.T) *prepareRequest {
|
||||||
|
|
||||||
req := &prepareRequest{
|
req := &prepareRequest{
|
||||||
timestamp: rand.Uint64(),
|
timestamp: rand.Uint64(),
|
||||||
nonce: rand.Uint64(),
|
|
||||||
transactionHashes: make([]util.Uint256, txCount),
|
transactionHashes: make([]util.Uint256, txCount),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ type prepareRequest struct {
|
||||||
version uint32
|
version uint32
|
||||||
prevHash util.Uint256
|
prevHash util.Uint256
|
||||||
timestamp uint64
|
timestamp uint64
|
||||||
nonce uint64
|
|
||||||
transactionHashes []util.Uint256
|
transactionHashes []util.Uint256
|
||||||
stateRootEnabled bool
|
stateRootEnabled bool
|
||||||
stateRoot util.Uint256
|
stateRoot util.Uint256
|
||||||
|
@ -25,7 +24,6 @@ func (p *prepareRequest) EncodeBinary(w *io.BinWriter) {
|
||||||
w.WriteU32LE(p.version)
|
w.WriteU32LE(p.version)
|
||||||
w.WriteBytes(p.prevHash[:])
|
w.WriteBytes(p.prevHash[:])
|
||||||
w.WriteU64LE(p.timestamp)
|
w.WriteU64LE(p.timestamp)
|
||||||
w.WriteU64LE(p.nonce)
|
|
||||||
w.WriteArray(p.transactionHashes)
|
w.WriteArray(p.transactionHashes)
|
||||||
if p.stateRootEnabled {
|
if p.stateRootEnabled {
|
||||||
w.WriteBytes(p.stateRoot[:])
|
w.WriteBytes(p.stateRoot[:])
|
||||||
|
@ -37,7 +35,6 @@ func (p *prepareRequest) DecodeBinary(r *io.BinReader) {
|
||||||
p.version = r.ReadU32LE()
|
p.version = r.ReadU32LE()
|
||||||
r.ReadBytes(p.prevHash[:])
|
r.ReadBytes(p.prevHash[:])
|
||||||
p.timestamp = r.ReadU64LE()
|
p.timestamp = r.ReadU64LE()
|
||||||
p.nonce = r.ReadU64LE()
|
|
||||||
r.ReadArray(&p.transactionHashes, block.MaxTransactionsPerBlock)
|
r.ReadArray(&p.transactionHashes, block.MaxTransactionsPerBlock)
|
||||||
if p.stateRootEnabled {
|
if p.stateRootEnabled {
|
||||||
r.ReadBytes(p.stateRoot[:])
|
r.ReadBytes(p.stateRoot[:])
|
||||||
|
@ -71,10 +68,10 @@ func (p *prepareRequest) Timestamp() uint64 { return p.timestamp * nsInMs }
|
||||||
func (p *prepareRequest) SetTimestamp(ts uint64) { p.timestamp = ts / nsInMs }
|
func (p *prepareRequest) SetTimestamp(ts uint64) { p.timestamp = ts / nsInMs }
|
||||||
|
|
||||||
// Nonce implements payload.PrepareRequest interface.
|
// Nonce implements payload.PrepareRequest interface.
|
||||||
func (p *prepareRequest) Nonce() uint64 { return p.nonce }
|
func (p *prepareRequest) Nonce() uint64 { return 0 }
|
||||||
|
|
||||||
// SetNonce implements payload.PrepareRequest interface.
|
// SetNonce implements payload.PrepareRequest interface.
|
||||||
func (p *prepareRequest) SetNonce(nonce uint64) { p.nonce = nonce }
|
func (p *prepareRequest) SetNonce(nonce uint64) {}
|
||||||
|
|
||||||
// TransactionHashes implements payload.PrepareRequest interface.
|
// TransactionHashes implements payload.PrepareRequest interface.
|
||||||
func (p *prepareRequest) TransactionHashes() []util.Uint256 { return p.transactionHashes }
|
func (p *prepareRequest) TransactionHashes() []util.Uint256 { return p.transactionHashes }
|
||||||
|
|
|
@ -24,9 +24,6 @@ func TestPrepareRequest_Setters(t *testing.T) {
|
||||||
p.SetNextConsensus(util.Uint160{5, 6, 7})
|
p.SetNextConsensus(util.Uint160{5, 6, 7})
|
||||||
require.Equal(t, util.Uint160{}, p.NextConsensus())
|
require.Equal(t, util.Uint160{}, p.NextConsensus())
|
||||||
|
|
||||||
p.SetNonce(8765)
|
|
||||||
require.EqualValues(t, 8765, p.Nonce())
|
|
||||||
|
|
||||||
hashes := [2]util.Uint256{random.Uint256(), random.Uint256()}
|
hashes := [2]util.Uint256{random.Uint256(), random.Uint256()}
|
||||||
|
|
||||||
p.SetTransactionHashes(hashes[:])
|
p.SetTransactionHashes(hashes[:])
|
||||||
|
@ -37,7 +34,6 @@ func TestPrepareRequest_EncodeDecodeBinary(t *testing.T) {
|
||||||
t.Run("positive", func(t *testing.T) {
|
t.Run("positive", func(t *testing.T) {
|
||||||
expected := &prepareRequest{
|
expected := &prepareRequest{
|
||||||
timestamp: 112,
|
timestamp: 112,
|
||||||
nonce: 1325,
|
|
||||||
transactionHashes: []util.Uint256{
|
transactionHashes: []util.Uint256{
|
||||||
random.Uint256(),
|
random.Uint256(),
|
||||||
random.Uint256(),
|
random.Uint256(),
|
||||||
|
@ -53,7 +49,6 @@ func TestPrepareRequest_EncodeDecodeBinary(t *testing.T) {
|
||||||
}
|
}
|
||||||
expected := &prepareRequest{
|
expected := &prepareRequest{
|
||||||
timestamp: 112,
|
timestamp: 112,
|
||||||
nonce: 1325,
|
|
||||||
transactionHashes: hashes,
|
transactionHashes: hashes,
|
||||||
}
|
}
|
||||||
data, err := testserdes.EncodeBinary(expected)
|
data, err := testserdes.EncodeBinary(expected)
|
||||||
|
|
|
@ -41,7 +41,6 @@ func testRecoveryMessageSetters(t *testing.T, enableStateRoot bool) {
|
||||||
|
|
||||||
req := &prepareRequest{
|
req := &prepareRequest{
|
||||||
timestamp: 87,
|
timestamp: 87,
|
||||||
nonce: 321,
|
|
||||||
transactionHashes: []util.Uint256{{1}},
|
transactionHashes: []util.Uint256{{1}},
|
||||||
stateRootEnabled: enableStateRoot,
|
stateRootEnabled: enableStateRoot,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue