*: drop miner transaction
1. Completely remove miner transaction 2. Change validation rule for block: block without transactions is valid.
This commit is contained in:
parent
55fd9f8d24
commit
29d321b5e1
24 changed files with 128 additions and 314 deletions
|
@ -2,7 +2,6 @@ package consensus
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"math/rand"
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
|
@ -10,7 +9,6 @@ import (
|
|||
"github.com/nspcc-dev/dbft/block"
|
||||
"github.com/nspcc-dev/dbft/crypto"
|
||||
"github.com/nspcc-dev/dbft/payload"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core"
|
||||
coreb "github.com/nspcc-dev/neo-go/pkg/core/block"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/blockchainer"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/mempool"
|
||||
|
@ -276,7 +274,6 @@ func (s *service) OnPayload(cp *Payload) {
|
|||
switch cp.Type() {
|
||||
case payload.PrepareRequestType:
|
||||
req := cp.GetPrepareRequest().(*prepareRequest)
|
||||
s.txx.Add(&req.minerTx)
|
||||
s.lastProposal = req.transactionHashes
|
||||
}
|
||||
|
||||
|
@ -316,12 +313,6 @@ func (s *service) GetPayload(h util.Uint256) *Payload {
|
|||
}
|
||||
|
||||
func (s *service) broadcast(p payload.ConsensusPayload) {
|
||||
switch p.Type() {
|
||||
case payload.PrepareRequestType:
|
||||
pr := p.GetPrepareRequest().(*prepareRequest)
|
||||
pr.minerTx = *s.txx.Get(pr.transactionHashes[0]).(*transaction.Transaction)
|
||||
}
|
||||
|
||||
if err := p.(*Payload).Sign(s.dbft.Priv.(*privateKey)); err != nil {
|
||||
s.log.Warn("can't sign consensus payload", zap.Error(err))
|
||||
}
|
||||
|
@ -442,40 +433,11 @@ func (s *service) getVerifiedTx(count int) []block.Transaction {
|
|||
txx = s.Config.Chain.ApplyPolicyToTxSet(txx)
|
||||
}
|
||||
|
||||
res := make([]block.Transaction, len(txx)+1)
|
||||
var netFee util.Fixed8
|
||||
res := make([]block.Transaction, len(txx))
|
||||
for i := range txx {
|
||||
res[i+1] = txx[i].Tx
|
||||
netFee += txx[i].Fee
|
||||
res[i] = txx[i].Tx
|
||||
}
|
||||
|
||||
var txOuts []transaction.Output
|
||||
if netFee != 0 {
|
||||
sh := s.wallet.GetChangeAddress()
|
||||
if sh.Equals(util.Uint160{}) {
|
||||
pk := s.dbft.Pub.(*publicKey)
|
||||
sh = pk.GetScriptHash()
|
||||
}
|
||||
txOuts = []transaction.Output{{
|
||||
AssetID: core.UtilityTokenID(),
|
||||
Amount: netFee,
|
||||
ScriptHash: sh,
|
||||
}}
|
||||
}
|
||||
for {
|
||||
minerTx := transaction.NewMinerTX()
|
||||
minerTx.Outputs = txOuts
|
||||
minerTx.ValidUntilBlock = s.dbft.BlockIndex
|
||||
minerTx.Nonce = rand.Uint32()
|
||||
res[0] = minerTx
|
||||
|
||||
if tx, _, _ := s.Chain.GetTransaction(res[0].Hash()); tx == nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
s.txx.Add(res[0])
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue