Skip to content

Commit 8805e79

Browse files
feedback
1 parent 0262ecd commit 8805e79

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

cache/metercacher/metrics.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func newCounterMetric(namespace, name string) prometheus.Counter {
2525
return prometheus.NewCounter(prometheus.CounterOpts{
2626
Namespace: namespace,
2727
Name: name,
28-
Help: fmt.Sprintf("# of times %s occurred", name),
28+
Help: fmt.Sprintf("# of times a %s occurred", name),
2929
})
3030
}
3131

vms/rpcchainvm/vm_client.go

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"github.com/ava-labs/avalanchego/snow/choices"
2424
"github.com/ava-labs/avalanchego/snow/consensus/snowman"
2525
"github.com/ava-labs/avalanchego/snow/engine/common"
26-
"github.com/ava-labs/avalanchego/utils/hashing"
2726
"github.com/ava-labs/avalanchego/utils/wrappers"
2827
"github.com/ava-labs/avalanchego/vms/components/missing"
2928
"github.com/ava-labs/avalanchego/vms/rpcchainvm/galiaslookup"
@@ -298,8 +297,10 @@ func (vm *VMClient) BuildBlock() (snowman.Block, error) {
298297

299298
id, err := ids.ToID(resp.Id)
300299
vm.ctx.Log.AssertNoError(err)
300+
301301
parentID, err := ids.ToID(resp.ParentID)
302302
vm.ctx.Log.AssertNoError(err)
303+
303304
vm.missingBlocks.Evict(id)
304305

305306
return &BlockClient{
@@ -314,17 +315,6 @@ func (vm *VMClient) BuildBlock() (snowman.Block, error) {
314315

315316
// ParseBlock ...
316317
func (vm *VMClient) ParseBlock(bytes []byte) (snowman.Block, error) {
317-
blkID := hashing.ComputeHash256Array(bytes)
318-
319-
if blk, cached := vm.blks[blkID]; cached {
320-
return blk, nil
321-
}
322-
if blkIntf, cached := vm.decidedBlocks.Get(blkID); cached {
323-
return blkIntf.(*BlockClient), nil
324-
}
325-
326-
vm.missingBlocks.Evict(blkID)
327-
328318
resp, err := vm.client.ParseBlock(context.Background(), &vmproto.ParseBlockRequest{
329319
Bytes: bytes,
330320
})
@@ -334,10 +324,18 @@ func (vm *VMClient) ParseBlock(bytes []byte) (snowman.Block, error) {
334324

335325
id, err := ids.ToID(resp.Id)
336326
vm.ctx.Log.AssertNoError(err)
337-
vm.ctx.Log.AssertTrue(id != blkID, "Unexpected blockID returned from plugin")
327+
328+
if blk, cached := vm.blks[id]; cached {
329+
return blk, nil
330+
}
331+
if blkIntf, cached := vm.decidedBlocks.Get(id); cached {
332+
return blkIntf.(*BlockClient), nil
333+
}
334+
vm.missingBlocks.Evict(id)
338335

339336
parentID, err := ids.ToID(resp.ParentID)
340337
vm.ctx.Log.AssertNoError(err)
338+
341339
status := choices.Status(resp.Status)
342340
vm.ctx.Log.AssertDeferredNoError(status.Valid)
343341

0 commit comments

Comments
 (0)