consensus: drop NextConsensus from the prepareRequest
Follow neo-project/neo#744 to make our requests compatible with C# node.
This commit is contained in:
parent
ae497228f0
commit
2278cd5700
5 changed files with 15 additions and 18 deletions
|
@ -464,15 +464,8 @@ func (s *service) getValidators(_ ...block.Transaction) []crypto.PublicKey {
|
|||
return pubs
|
||||
}
|
||||
|
||||
func (s *service) getConsensusAddress(validators ...crypto.PublicKey) (h util.Uint160) {
|
||||
pubs := convertKeys(validators)
|
||||
|
||||
script, err := smartcontract.CreateMultiSigRedeemScript(s.dbft.M(), pubs)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
return crypto.Hash160(script)
|
||||
func (s *service) getConsensusAddress(validators ...crypto.PublicKey) util.Uint160 {
|
||||
return util.Uint160{}
|
||||
}
|
||||
|
||||
func convertKeys(validators []crypto.PublicKey) (pubs []*keys.PublicKey) {
|
||||
|
@ -493,7 +486,16 @@ func (s *service) newBlockFromContext(ctx *dbft.Context) block.Block {
|
|||
block.Block.Network = s.network
|
||||
block.Block.Timestamp = ctx.Timestamp / 1000000
|
||||
block.Block.Index = ctx.BlockIndex
|
||||
block.Block.NextConsensus = ctx.NextConsensus
|
||||
|
||||
validators, err := s.Chain.GetValidators()
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
script, err := smartcontract.CreateMultiSigRedeemScript(len(validators)-(len(validators)-1)/3, validators)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
block.Block.NextConsensus = crypto.Hash160(script)
|
||||
block.Block.PrevHash = ctx.PrevHash
|
||||
block.Block.Version = ctx.Version
|
||||
block.Block.ConsensusData.Nonce = ctx.Nonce
|
||||
|
|
|
@ -256,7 +256,6 @@ func randomPrepareRequest(t *testing.T) *prepareRequest {
|
|||
for i := 0; i < txCount; i++ {
|
||||
req.transactionHashes[i] = random.Uint256()
|
||||
}
|
||||
req.nextConsensus = random.Uint160()
|
||||
|
||||
return req
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ type prepareRequest struct {
|
|||
timestamp uint64
|
||||
nonce uint64
|
||||
transactionHashes []util.Uint256
|
||||
nextConsensus util.Uint160
|
||||
}
|
||||
|
||||
var _ payload.PrepareRequest = (*prepareRequest)(nil)
|
||||
|
@ -20,7 +19,6 @@ var _ payload.PrepareRequest = (*prepareRequest)(nil)
|
|||
func (p *prepareRequest) EncodeBinary(w *io.BinWriter) {
|
||||
w.WriteU64LE(p.timestamp)
|
||||
w.WriteU64LE(p.nonce)
|
||||
w.WriteBytes(p.nextConsensus[:])
|
||||
w.WriteArray(p.transactionHashes)
|
||||
}
|
||||
|
||||
|
@ -28,7 +26,6 @@ func (p *prepareRequest) EncodeBinary(w *io.BinWriter) {
|
|||
func (p *prepareRequest) DecodeBinary(r *io.BinReader) {
|
||||
p.timestamp = r.ReadU64LE()
|
||||
p.nonce = r.ReadU64LE()
|
||||
r.ReadBytes(p.nextConsensus[:])
|
||||
r.ReadArray(&p.transactionHashes)
|
||||
}
|
||||
|
||||
|
@ -51,7 +48,7 @@ func (p *prepareRequest) TransactionHashes() []util.Uint256 { return p.transacti
|
|||
func (p *prepareRequest) SetTransactionHashes(hs []util.Uint256) { p.transactionHashes = hs }
|
||||
|
||||
// NextConsensus implements payload.PrepareRequest interface.
|
||||
func (p *prepareRequest) NextConsensus() util.Uint160 { return p.nextConsensus }
|
||||
func (p *prepareRequest) NextConsensus() util.Uint160 { return util.Uint160{} }
|
||||
|
||||
// SetNextConsensus implements payload.PrepareRequest interface.
|
||||
func (p *prepareRequest) SetNextConsensus(nc util.Uint160) { p.nextConsensus = nc }
|
||||
func (p *prepareRequest) SetNextConsensus(_ util.Uint160) {}
|
||||
|
|
|
@ -20,7 +20,7 @@ func TestPrepareRequest_Setters(t *testing.T) {
|
|||
require.EqualValues(t, 1000000, p.Timestamp())
|
||||
|
||||
p.SetNextConsensus(util.Uint160{5, 6, 7})
|
||||
require.Equal(t, util.Uint160{5, 6, 7}, p.NextConsensus())
|
||||
require.Equal(t, util.Uint160{}, p.NextConsensus())
|
||||
|
||||
p.SetNonce(8765)
|
||||
require.EqualValues(t, 8765, p.Nonce())
|
||||
|
|
|
@ -31,7 +31,6 @@ func TestRecoveryMessage_Setters(t *testing.T) {
|
|||
timestamp: 87,
|
||||
nonce: 321,
|
||||
transactionHashes: []util.Uint256{{1}},
|
||||
nextConsensus: util.Uint160{1, 2},
|
||||
}
|
||||
p1 := new(Payload)
|
||||
p1.message = &message{}
|
||||
|
|
Loading…
Reference in a new issue