Commit eb7d1b37 authored by 李伟@五瓣科技's avatar 李伟@五瓣科技

fix take for

parent 5c719026
......@@ -756,11 +756,13 @@ func (web *WebServicer) sendBatchTxsFromQueue(fromAddr string, toAddrs []string,
var hashesBytes []byte = make([]byte, 0, 32*batchTxHashSize)
if txF, ok := txAsInterface.(TxWithFrom); ok {
for j := 0; j < batchTxHashSize; j++ {
j := 0
for ; j < batchTxHashSize; j++ {
var txsBytes []byte
var batchTxs []TxWithFrom = make([]TxWithFrom, 0, batchTxSize)
for i := 0; i < batchTxSize; i++ {
i := 0
for ; i < batchTxSize; i++ {
if k == 0 {
beginOriginalTx = txF.Tx.Hash()
}
......@@ -778,30 +780,37 @@ func (web *WebServicer) sendBatchTxsFromQueue(fromAddr string, toAddrs []string,
}
}
h := sha256.New()
if _, err := h.Write(txsBytes); err != nil {
return err
}
if i == batchTxSize-1 || k == len(txFs)-1 {
hashBytes := h.Sum(nil)
hashesBytes = append(hashesBytes, hashBytes...)
redisTxlist = append(redisTxlist, OriginalBatchTxs{Hash: hashBytes, Txs: batchTxs})
h := sha256.New()
if _, err := h.Write(txsBytes); err != nil {
return err
}
if k == len(txFs)-1 {
endOriginalTx = txF.Tx.Hash()
break
hashBytes := h.Sum(nil)
hashesBytes = append(hashesBytes, hashBytes...)
redisTxlist = append(redisTxlist, OriginalBatchTxs{Hash: hashBytes, Txs: batchTxs})
if k == len(txFs)-1 {
endOriginalTx = txF.Tx.Hash()
break
}
}
}
tx, err := web.cli.BuildTx(&hashesBytes)
if j == batchTxHashSize-1 || k == len(txFs)-1 {
if err != nil {
return err
}
tx, err := web.cli.BuildTx(&hashesBytes)
consenusTxs = append(consenusTxs, tx)
consTxWithBatchs = append(consTxWithBatchs, ConsTxWithBatchHash{ConsTxHash: tx.Hash().Bytes(),
BatchTxsHash: hashesBytes})
if err != nil {
return err
}
consenusTxs = append(consenusTxs, tx)
consTxWithBatchs = append(consTxWithBatchs, ConsTxWithBatchHash{ConsTxHash: tx.Hash().Bytes(),
BatchTxsHash: hashesBytes})
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment