(ids [][]byte, pubPoly *share.PubPoly, sec *share.PriShare, groupID string, requestID, lastRand, useSeed *big.Int, url, selector string, pType uint32)
| 68 | } |
| 69 | |
| 70 | func (d *DosNode) handleQuery(ids [][]byte, pubPoly *share.PubPoly, sec *share.PriShare, groupID string, requestID, lastRand, useSeed *big.Int, url, selector string, pType uint32) { |
| 71 | queryCtx, cancel := context.WithTimeout(context.Background(), time.Duration(60*15*time.Second)) |
| 72 | defer cancel() |
| 73 | queryCtxWithValue := context.WithValue(context.WithValue(queryCtx, ctxKey("RequestID"), fmt.Sprintf("%x", requestID)), ctxKey("GroupID"), groupID) |
| 74 | d.logger.Event("HandleQuery", map[string]interface{}{"GroupID": groupID, "RequestID": fmt.Sprintf("%x", requestID)}) |
| 75 | defer d.logger.TimeTrack(time.Now(), "TimeHandleQuery", map[string]interface{}{"GroupID": groupID, "RequestID": fmt.Sprintf("%x", requestID)}) |
| 76 | defer cancel() |
| 77 | var nonce []byte |
| 78 | //Generate an unique id |
| 79 | switch pType { |
| 80 | case onchain.TrafficSystemRandom: |
| 81 | var bytes []byte |
| 82 | bytes = append(bytes, []byte(groupID)...) |
| 83 | bytes = append(bytes, requestID.Bytes()...) |
| 84 | bytes = append(bytes, lastRand.Bytes()...) |
| 85 | nHash := sha256.Sum256(bytes) |
| 86 | nonce = nHash[:] |
| 87 | case onchain.TrafficUserRandom: |
| 88 | var bytes []byte |
| 89 | bytes = append(bytes, []byte(groupID)...) |
| 90 | bytes = append(bytes, requestID.Bytes()...) |
| 91 | bytes = append(bytes, lastRand.Bytes()...) |
| 92 | bytes = append(bytes, useSeed.Bytes()...) |
| 93 | nHash := sha256.Sum256(bytes) |
| 94 | nonce = nHash[:] |
| 95 | case onchain.TrafficUserQuery: |
| 96 | var bytes []byte |
| 97 | bytes = append(bytes, []byte(groupID)...) |
| 98 | bytes = append(bytes, requestID.Bytes()...) |
| 99 | bytes = append(bytes, lastRand.Bytes()...) |
| 100 | bytes = append(bytes, []byte(url)...) |
| 101 | bytes = append(bytes, []byte(selector)...) |
| 102 | nHash := sha256.Sum256(bytes) |
| 103 | nonce = nHash[:] |
| 104 | } |
| 105 | sign := &vss.Signature{ |
| 106 | Index: pType, |
| 107 | RequestId: requestID.Bytes(), |
| 108 | Nonce: nonce, |
| 109 | } |
| 110 | //Build a pipeline |
| 111 | var errcList []chan error |
| 112 | |
| 113 | submitterc, errc := choseSubmitter(queryCtxWithValue, d.p, d.chain, lastRand, ids, 2, d.logger) |
| 114 | errcList = append(errcList, errc) |
| 115 | |
| 116 | var contentc chan []byte |
| 117 | switch pType { |
| 118 | case onchain.TrafficSystemRandom: |
| 119 | contentc = genSysRandom(queryCtxWithValue, submitterc[0], lastRand.Bytes(), d.logger) |
| 120 | case onchain.TrafficUserRandom: |
| 121 | contentc = genUserRandom(queryCtxWithValue, submitterc[0], requestID.Bytes(), lastRand.Bytes(), useSeed.Bytes(), d.logger) |
| 122 | case onchain.TrafficUserQuery: |
| 123 | contentc, errc = genQueryResult(queryCtxWithValue, submitterc[0], url, selector, d.logger) |
| 124 | errcList = append(errcList, errc) |
| 125 | } |
| 126 | |
| 127 | signc, errc := genSign(queryCtxWithValue, contentc, sec, d.suite, sign, d.logger) |
no test coverage detected