• R/O
  • HTTP
  • SSH
  • HTTPS

vapor: 提交

Golang implemented sidechain for Bytom


Commit MetaInfo

修订版de7dbf2a4c2281f87d7500ae52a0ab28bfc73aaf (tree)
时间2020-02-06 19:39:34
作者Poseidon <shenao.78@163....>
CommiterGitHub

Log Message

fix match collector (#481)

* fix match collector

* add comment

更改概述

差异

--- a/application/mov/match_collector.go
+++ b/application/mov/match_collector.go
@@ -63,6 +63,15 @@ func (m *matchCollector) collect() ([]*types.Tx, error) {
6363 defer close(m.closeCh)
6464
6565 var matchedTxs []*types.Tx
66+ appendMatchedTxs := func(data *matchTxResult) bool {
67+ gasUsed := calcMatchedTxGasUsed(data.matchedTx)
68+ if m.gasLeft -= gasUsed; m.gasLeft >= 0 {
69+ matchedTxs = append(matchedTxs, data.matchedTx)
70+ return false
71+ }
72+ return true
73+ }
74+
6675 completed := 0
6776 for !m.isTimeout() {
6877 select {
@@ -71,14 +80,20 @@ func (m *matchCollector) collect() ([]*types.Tx, error) {
7180 return nil, data.err
7281 }
7382
74- gasUsed := calcMatchedTxGasUsed(data.matchedTx)
75- if m.gasLeft -= gasUsed; m.gasLeft >= 0 {
76- matchedTxs = append(matchedTxs, data.matchedTx)
77- } else {
83+ if done := appendMatchedTxs(data); done {
7884 return matchedTxs, nil
7985 }
8086 case <-m.workerNumCh:
8187 if completed++; completed == m.workerNum {
88+ // read the remaining process results
89+ close(m.processCh)
90+ for data := range m.processCh {
91+ if data.err != nil {
92+ return nil, data.err
93+ }
94+
95+ appendMatchedTxs(data)
96+ }
8297 return matchedTxs, nil
8398 }
8499 }
Show on old repository browser