|
|
@ -419,16 +419,18 @@ func (consensus *Consensus) reportMetrics(block blockchain.Block) { |
|
|
|
|
|
|
|
|
|
|
|
// Post metrics
|
|
|
|
// Post metrics
|
|
|
|
URL := "http://localhost:3000/report" |
|
|
|
URL := "http://localhost:3000/report" |
|
|
|
|
|
|
|
txHashes := []string{} |
|
|
|
|
|
|
|
for i := 1; i <= 3; i++ { |
|
|
|
|
|
|
|
if len(block.TransactionIds)-i >= 0 { |
|
|
|
|
|
|
|
txHashes = append(txHashes, hex.EncodeToString(block.TransactionIds[len(block.TransactionIds)-i][:])) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
form := url.Values{ |
|
|
|
form := url.Values{ |
|
|
|
"tps": {strconv.FormatFloat(tps, 'f', 2, 64)}, |
|
|
|
"tps": {strconv.FormatFloat(tps, 'f', 2, 64)}, |
|
|
|
"txCount": {strconv.Itoa(int(numOfTxs))}, |
|
|
|
"txCount": {strconv.Itoa(int(numOfTxs))}, |
|
|
|
"nodeCount": {strconv.Itoa(len(consensus.validators) + 1)}, |
|
|
|
"nodeCount": {strconv.Itoa(len(consensus.validators) + 1)}, |
|
|
|
"latestBlockHash": {hex.EncodeToString(consensus.blockHash[:])}, |
|
|
|
"latestBlockHash": {hex.EncodeToString(consensus.blockHash[:])}, |
|
|
|
"latestTxHashes": { |
|
|
|
"latestTxHashes": txHashes, |
|
|
|
hex.EncodeToString(block.TransactionIds[len(block.TransactionIds)-1][:]), |
|
|
|
|
|
|
|
hex.EncodeToString(block.TransactionIds[len(block.TransactionIds)-2][:]), |
|
|
|
|
|
|
|
hex.EncodeToString(block.TransactionIds[len(block.TransactionIds)-3][:]), |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
"blockLatency": {strconv.Itoa(int(timeElapsed / time.Millisecond))}, |
|
|
|
"blockLatency": {strconv.Itoa(int(timeElapsed / time.Millisecond))}, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|