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"
ProposeMethod = "0x01267951"
ResignMethod = "0xae6e43f5"
SignMethod = "0xe341eaa4"
)
var (

View file

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

View file

@ -291,7 +291,22 @@ func (tx *Transaction) IsSigningTransaction() bool {
if tx.To() == nil {
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) {