who mined block

This commit is contained in:
Anton Evangelatov 2020-06-26 22:07:49 +02:00
parent 0487d60d0e
commit 0d908c18b4
2 changed files with 58 additions and 8 deletions

View File

@ -16,7 +16,7 @@
"gnetId": null,
"graphTooltip": 0,
"id": 16,
"iteration": 1593188264284,
"iteration": 1593201827692,
"links": [],
"panels": [
{
@ -180,6 +180,12 @@
],
"type": "tag"
},
{
"params": [
"miner"
],
"type": "tag"
},
{
"params": [
"0"
@ -187,7 +193,7 @@
"type": "fill"
}
],
"measurement": "diagnostics.miner.mine.counter",
"measurement": "diagnostics.block.mine.counter",
"orderByTime": "ASC",
"policy": "default",
"refId": "A",
@ -207,6 +213,48 @@
]
],
"tags": []
},
{
"groupBy": [
{
"params": [
"$myinterval"
],
"type": "time"
},
{
"params": [
"run"
],
"type": "tag"
},
{
"params": [
"0"
],
"type": "fill"
}
],
"measurement": "diagnostics.block.mine.counter",
"orderByTime": "ASC",
"policy": "default",
"refId": "B",
"resultFormat": "time_series",
"select": [
[
{
"params": [
"count"
],
"type": "field"
},
{
"params": [],
"type": "sum"
}
]
],
"tags": []
}
],
"thresholds": [],
@ -918,5 +966,5 @@
"timezone": "",
"title": "Project Oni - Baseline test",
"uid": "8em8RXWMz",
"version": 4
"version": 6
}

View File

@ -37,6 +37,11 @@ func runMiner(t *TestEnvironment) error {
clients := t.IntParam("clients")
miners := t.IntParam("miners")
myActorAddr, err := miner.minerApi.ActorAddress(ctx)
if err != nil {
return err
}
// mine / stop mining
mine := true
done := make(chan struct{})
@ -44,7 +49,6 @@ func runMiner(t *TestEnvironment) error {
defer close(done)
var i int
for i = 0; mine; i++ {
// synchronize all miners to mine the next block
t.RecordMessage("synchronizing all miners to mine next block [%d]", i)
stateMineNext := sync.State(fmt.Sprintf("mine-block-%d", i))
@ -53,10 +57,8 @@ func runMiner(t *TestEnvironment) error {
// add some random delay to encourage a different miner winning each round
time.Sleep(time.Duration(100 + rand.Intn(int(100*time.Millisecond))))
err := miner.MineOne(ctx, func(bool) {
t.D().Counter("miner.mine").Inc(1)
// after a block is mined
err := miner.MineOne(ctx, func(mined bool) {
t.D().Counter(fmt.Sprintf("block.mine,miner=%s", myActorAddr)).Inc(1)
})
if err != nil {
panic(err)