Golang implemented sidechain for Bytom
修订版 | 1b35511b58dac0acdc5ca3f4f539a00d73a42430 (tree) |
---|---|
时间 | 2019-07-17 15:01:16 |
作者 | oysheng <33340252+oysheng@user...> |
Commiter | Paladz |
delete first tx vote amount restrict (#301)
@@ -108,11 +108,6 @@ func NewBlockTemplate(c *protocol.Chain, txPool *protocol.TxPool, accountManager | ||
108 | 108 | txs := txPool.GetTransactions() |
109 | 109 | sort.Sort(byTime(txs)) |
110 | 110 | |
111 | - consensusResult, err := c.GetConsensusResultByHash(&preBlockHash) | |
112 | - if err != nil { | |
113 | - return nil, err | |
114 | - } | |
115 | - | |
116 | 111 | entriesTxs := []*bc.Tx{} |
117 | 112 | for _, txDesc := range txs { |
118 | 113 | entriesTxs = append(entriesTxs, txDesc.Tx.Tx) |
@@ -147,11 +142,6 @@ func NewBlockTemplate(c *protocol.Chain, txPool *protocol.TxPool, accountManager | ||
147 | 142 | continue |
148 | 143 | } |
149 | 144 | |
150 | - if err := consensusResult.ApplyTransaction(txDesc.Tx); err != nil { | |
151 | - blkGenSkipTxForErr(txPool, &tx.ID, err) | |
152 | - continue | |
153 | - } | |
154 | - | |
155 | 145 | if err := txStatus.SetStatus(len(b.Transactions), gasOnlyTx); err != nil { |
156 | 146 | return nil, err |
157 | 147 | } |
@@ -171,6 +161,11 @@ func NewBlockTemplate(c *protocol.Chain, txPool *protocol.TxPool, accountManager | ||
171 | 161 | return nil, errors.Wrap(err, "fail on createCoinbaseTx") |
172 | 162 | } |
173 | 163 | |
164 | + consensusResult, err := c.GetConsensusResultByHash(&preBlockHash) | |
165 | + if err != nil { | |
166 | + return nil, err | |
167 | + } | |
168 | + | |
174 | 169 | if err := consensusResult.AttachCoinbaseReward(b); err != nil { |
175 | 170 | return nil, err |
176 | 171 | } |
@@ -145,15 +145,7 @@ func (c *ConsensusResult) ApplyTransaction(tx *types.Tx) error { | ||
145 | 145 | continue |
146 | 146 | } |
147 | 147 | |
148 | - if voteOutput.Amount < consensus.ActiveNetParams.MinVoteOutputAmount { | |
149 | - return errors.New("invalid vote transaction with vote amount less than MinVoteOutputAmount") | |
150 | - } | |
151 | - | |
152 | 148 | pubkey := hex.EncodeToString(voteOutput.Vote) |
153 | - if _, ok := c.NumOfVote[pubkey]; !ok && voteOutput.Amount < consensus.ActiveNetParams.MinConsensusNodeVoteNum { | |
154 | - return errors.New("invalid vote transaction with first vote amount less than MinConsensusNodeVoteNum") | |
155 | - } | |
156 | - | |
157 | 149 | if c.NumOfVote[pubkey], ok = checked.AddUint64(c.NumOfVote[pubkey], voteOutput.Amount); !ok { |
158 | 150 | return checked.ErrOverflow |
159 | 151 | } |
@@ -3,7 +3,6 @@ package protocol | ||
3 | 3 | import ( |
4 | 4 | log "github.com/sirupsen/logrus" |
5 | 5 | |
6 | - "github.com/vapor/errors" | |
7 | 6 | "github.com/vapor/protocol/bc" |
8 | 7 | "github.com/vapor/protocol/bc/types" |
9 | 8 | "github.com/vapor/protocol/state" |
@@ -45,16 +44,6 @@ func (c *Chain) validateTx(tx *types.Tx) (bool, error) { | ||
45 | 44 | } |
46 | 45 | |
47 | 46 | bh := c.BestBlockHeader() |
48 | - blockHash := bh.Hash() | |
49 | - consensusResult, err := c.GetConsensusResultByHash(&blockHash) | |
50 | - if err != nil { | |
51 | - return false, err | |
52 | - } | |
53 | - | |
54 | - if err := consensusResult.ApplyTransaction(tx); err != nil { | |
55 | - return false, errors.Wrap(validation.ErrVoteOutputAmount, err) | |
56 | - } | |
57 | - | |
58 | 47 | gasStatus, err := validation.ValidateTx(tx.Tx, types.MapBlock(&types.Block{BlockHeader: *bh})) |
59 | 48 | if !gasStatus.GasValid { |
60 | 49 | c.txPool.AddErrCache(&tx.ID, err) |
@@ -245,6 +245,10 @@ func checkValid(vs *validationState, e bc.Entry) (err error) { | ||
245 | 245 | return errors.Wrap(err, "checking vote output source") |
246 | 246 | } |
247 | 247 | |
248 | + if e.Source.Value.Amount < consensus.ActiveNetParams.MinVoteOutputAmount { | |
249 | + return ErrVoteOutputAmount | |
250 | + } | |
251 | + | |
248 | 252 | case *bc.Retirement: |
249 | 253 | vs2 := *vs |
250 | 254 | vs2.sourcePos = 0 |