|
|
@ -404,39 +404,41 @@ func (consensus *Consensus) verifyResponse(commitments *map[uint16]kyber.Point, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (consensus *Consensus) reportMetrics(block blockchain.Block) { |
|
|
|
func (consensus *Consensus) reportMetrics(block blockchain.Block) { |
|
|
|
endTime := time.Now() |
|
|
|
if !block.IsStateBlock() { // Skip state block stats
|
|
|
|
timeElapsed := endTime.Sub(startTime) |
|
|
|
endTime := time.Now() |
|
|
|
numOfTxs := block.NumTransactions |
|
|
|
timeElapsed := endTime.Sub(startTime) |
|
|
|
tps := float64(numOfTxs) / timeElapsed.Seconds() |
|
|
|
numOfTxs := block.NumTransactions |
|
|
|
consensus.Log.Info("TPS Report", |
|
|
|
tps := float64(numOfTxs) / timeElapsed.Seconds() |
|
|
|
"numOfTXs", numOfTxs, |
|
|
|
consensus.Log.Info("TPS Report", |
|
|
|
"startTime", startTime, |
|
|
|
"numOfTXs", numOfTxs, |
|
|
|
"endTime", endTime, |
|
|
|
"startTime", startTime, |
|
|
|
"timeElapsed", timeElapsed, |
|
|
|
"endTime", endTime, |
|
|
|
"TPS", tps, |
|
|
|
"timeElapsed", timeElapsed, |
|
|
|
"consensus", consensus) |
|
|
|
"TPS", tps, |
|
|
|
|
|
|
|
"consensus", consensus) |
|
|
|
// Post metrics
|
|
|
|
|
|
|
|
URL := "http://localhost:3000/report" |
|
|
|
// Post metrics
|
|
|
|
txHashes := []string{} |
|
|
|
URL := "http://localhost:3000/report" |
|
|
|
for i := 1; i <= 3; i++ { |
|
|
|
txHashes := []string{} |
|
|
|
if len(block.TransactionIds)-i >= 0 { |
|
|
|
for i := 1; i <= 3; i++ { |
|
|
|
txHashes = append(txHashes, hex.EncodeToString(block.TransactionIds[len(block.TransactionIds)-i][:])) |
|
|
|
if len(block.TransactionIds)-i >= 0 { |
|
|
|
|
|
|
|
txHashes = append(txHashes, hex.EncodeToString(block.TransactionIds[len(block.TransactionIds)-i][:])) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
form := url.Values{ |
|
|
|
|
|
|
|
"key": {consensus.pubKey.String()}, |
|
|
|
|
|
|
|
"tps": {strconv.FormatFloat(tps, 'f', 2, 64)}, |
|
|
|
|
|
|
|
"txCount": {strconv.Itoa(int(numOfTxs))}, |
|
|
|
|
|
|
|
"nodeCount": {strconv.Itoa(len(consensus.validators) + 1)}, |
|
|
|
|
|
|
|
"latestBlockHash": {hex.EncodeToString(consensus.blockHash[:])}, |
|
|
|
|
|
|
|
"latestTxHashes": txHashes, |
|
|
|
|
|
|
|
"blockLatency": {strconv.Itoa(int(timeElapsed / time.Millisecond))}, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
form := url.Values{ |
|
|
|
|
|
|
|
"key": {consensus.pubKey.String()}, |
|
|
|
|
|
|
|
"tps": {strconv.FormatFloat(tps, 'f', 2, 64)}, |
|
|
|
|
|
|
|
"txCount": {strconv.Itoa(int(numOfTxs))}, |
|
|
|
|
|
|
|
"nodeCount": {strconv.Itoa(len(consensus.validators) + 1)}, |
|
|
|
|
|
|
|
"latestBlockHash": {hex.EncodeToString(consensus.blockHash[:])}, |
|
|
|
|
|
|
|
"latestTxHashes": txHashes, |
|
|
|
|
|
|
|
"blockLatency": {strconv.Itoa(int(timeElapsed / time.Millisecond))}, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
body := bytes.NewBufferString(form.Encode()) |
|
|
|
body := bytes.NewBufferString(form.Encode()) |
|
|
|
rsp, err := http.Post(URL, "application/x-www-form-urlencoded", body) |
|
|
|
rsp, err := http.Post(URL, "application/x-www-form-urlencoded", body) |
|
|
|
if err == nil { |
|
|
|
if err == nil { |
|
|
|
defer rsp.Body.Close() |
|
|
|
defer rsp.Body.Close() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|