OSDN Git Service
(root)
/
bytom
/
vapor.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
31befe7
)
fix the lock bug (#316)
author
Paladz
<yzhu101@uottawa.ca>
Thu, 18 Jul 2019 08:16:44 +0000
(16:16 +0800)
committer
GitHub
<noreply@github.com>
Thu, 18 Jul 2019 08:16:44 +0000
(16:16 +0800)
protocol/block.go
patch
|
blob
|
history
protocol/tx.go
patch
|
blob
|
history
diff --git
a/protocol/block.go
b/protocol/block.go
index
9552a01
..
6300951
100644
(file)
--- a/
protocol/block.go
+++ b/
protocol/block.go
@@
-238,7
+238,7
@@
func (c *Chain) reorganizeChain(blockHeader *types.BlockHeader) error {
// the number of restored Tx should be very small or most of time ZERO
// Error returned from validation is ignored, tx could still be lost if validation fails.
// TODO: adjust tx timestamp so that it won't starve in pool.
// the number of restored Tx should be very small or most of time ZERO
// Error returned from validation is ignored, tx could still be lost if validation fails.
// TODO: adjust tx timestamp so that it won't starve in pool.
- if _, err := c.validateTx(tx); err != nil {
+ if _, err := c.validateTx(tx
, blockHeader
); err != nil {
log.WithFields(log.Fields{"module": logModule, "tx_id": tx.Tx.ID.String(), "error": err}).Info("restore tx fail")
}
}
log.WithFields(log.Fields{"module": logModule, "tx_id": tx.Tx.ID.String(), "error": err}).Info("restore tx fail")
}
}
diff --git
a/protocol/tx.go
b/protocol/tx.go
index
3562706
..
bdd3516
100644
(file)
--- a/
protocol/tx.go
+++ b/
protocol/tx.go
@@
-28,11
+28,12
@@
func (c *Chain) ValidateTx(tx *types.Tx) (bool, error) {
}
c.markTransactions(tx)
}
c.markTransactions(tx)
- return c.validateTx(tx)
+ bh := c.BestBlockHeader()
+ return c.validateTx(tx, bh)
}
// validateTx validates the given transaction without checking duplication.
}
// validateTx validates the given transaction without checking duplication.
-func (c *Chain) validateTx(tx *types.Tx) (bool, error) {
+func (c *Chain) validateTx(tx *types.Tx
, bh *types.BlockHeader
) (bool, error) {
if ok := c.txPool.HaveTransaction(&tx.ID); ok {
return false, c.txPool.GetErrCache(&tx.ID)
}
if ok := c.txPool.HaveTransaction(&tx.ID); ok {
return false, c.txPool.GetErrCache(&tx.ID)
}
@@
-42,7
+43,6
@@
func (c *Chain) validateTx(tx *types.Tx) (bool, error) {
return false, ErrDustTx
}
return false, ErrDustTx
}
- bh := c.BestBlockHeader()
gasStatus, err := validation.ValidateTx(tx.Tx, types.MapBlock(&types.Block{BlockHeader: *bh}))
if !gasStatus.GasValid {
c.txPool.AddErrCache(&tx.ID, err)
gasStatus, err := validation.ValidateTx(tx.Tx, types.MapBlock(&types.Block{BlockHeader: *bh}))
if !gasStatus.GasValid {
c.txPool.AddErrCache(&tx.ID, err)