verify signing tx

This commit is contained in:
Nguyen Sy Thanh Son 2019-01-11 17:14:12 +00:00
parent cd81c5c8b6
commit 381864d869
3 changed files with 32 additions and 14 deletions

View file

@ -39,6 +39,7 @@ const (
UnvoteMethod = "0x02aa9be2" UnvoteMethod = "0x02aa9be2"
ProposeMethod = "0x01267951" ProposeMethod = "0x01267951"
ResignMethod = "0xae6e43f5" ResignMethod = "0xae6e43f5"
SignMethod = "0xe341eaa4"
) )
var ( var (

View file

@ -336,22 +336,24 @@ func GetRewardForCheckpoint(c *posv.Posv, chain consensus.ChainReader, number ui
var signTxs []*types.Transaction var signTxs []*types.Transaction
for _, tx := range txs { for _, tx := range txs {
var b uint if tx.IsSigningTransaction() {
for _, r := range receipts { var b uint
if r.TxHash == tx.Hash() { for _, r := range receipts {
b = r.Status if r.TxHash == tx.Hash() {
break b = r.Status
break
}
} }
}
if b == types.ReceiptStatusFailed { if b == types.ReceiptStatusFailed {
continue continue
} }
signTxs = append(signTxs, tx) signTxs = append(signTxs, tx)
blkHash := common.BytesToHash(tx.Data()[len(tx.Data())-32:]) blkHash := common.BytesToHash(tx.Data()[len(tx.Data())-32:])
from := *tx.From() from := *tx.From()
data[blkHash] = append(data[blkHash], from) data[blkHash] = append(data[blkHash], from)
}
} }
c.BlockSigners.Add(header.Hash(), signTxs) c.BlockSigners.Add(header.Hash(), signTxs)

View file

@ -291,7 +291,22 @@ func (tx *Transaction) IsSigningTransaction() bool {
if tx.To() == nil { if tx.To() == nil {
return false return false
} }
return tx.To().String() == common.BlockSigners
if tx.To().String() != common.BlockSigners {
return false
}
method := common.ToHex(tx.Data()[0:4])
if method != common.SignMethod {
return false
}
if len(tx.Data()) != (32*2 + 4) {
return false
}
return true
} }
func (tx *Transaction) IsVotingTransaction() (bool, *common.Address) { func (tx *Transaction) IsVotingTransaction() (bool, *common.Address) {