Fixed duplicate nonce value for randomize and sign txs

This commit is contained in:
DinhLN 2018-10-06 10:29:52 +07:00
parent 9a8be4e031
commit 4c2c909f0f

View file

@ -95,9 +95,7 @@ func CreateTransactionSign(chainConfig *params.ChainConfig, pool *core.TxPool, m
// Only process when private key empty in state db.
// Save randomize key into state db.
randomizeKeyValue := RandStringByte(32)
chainDb.Put(randomizeKeyName, randomizeKeyValue)
tx, err := BuildTxSecretRandomize(nonce, common.HexToAddress(common.RandomizeSMC), chainConfig.Posv.Epoch, randomizeKeyValue)
tx, err := BuildTxSecretRandomize(nonce+1, common.HexToAddress(common.RandomizeSMC), chainConfig.Posv.Epoch, randomizeKeyValue)
if err != nil {
log.Error("Fail to get tx opening for randomize", "error", err)
return err
@ -112,6 +110,9 @@ func CreateTransactionSign(chainConfig *params.ChainConfig, pool *core.TxPool, m
if err != nil {
log.Error("Fail to add tx secret to local pool.", "error", err)
}
// Put randomize key into chainDb.
chainDb.Put(randomizeKeyName, randomizeKeyValue)
}
// Set opening for randomize.
@ -121,7 +122,7 @@ func CreateTransactionSign(chainConfig *params.ChainConfig, pool *core.TxPool, m
log.Error("Fail to get randomize key from state db.", "error", err)
}
tx, err := BuildTxOpeningRandomize(nonce, common.HexToAddress(common.RandomizeSMC), randomizeKeyValue)
tx, err := BuildTxOpeningRandomize(nonce+1, common.HexToAddress(common.RandomizeSMC), randomizeKeyValue)
if err != nil {
log.Error("Fail to get tx opening for randomize", "error", err)
return err