github.com/MetalBlockchain/metalgo@v1.11.9/vms/tracedvm/tx.go (about)

     1  // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
     2  // See the file LICENSE for licensing terms.
     3  
     4  package tracedvm
     5  
     6  import (
     7  	"context"
     8  
     9  	"go.opentelemetry.io/otel/attribute"
    10  
    11  	"github.com/MetalBlockchain/metalgo/snow/consensus/snowstorm"
    12  	"github.com/MetalBlockchain/metalgo/trace"
    13  
    14  	oteltrace "go.opentelemetry.io/otel/trace"
    15  )
    16  
    17  var _ snowstorm.Tx = (*tracedTx)(nil)
    18  
    19  type tracedTx struct {
    20  	snowstorm.Tx
    21  
    22  	tracer trace.Tracer
    23  }
    24  
    25  func (t *tracedTx) Verify(ctx context.Context) error {
    26  	ctx, span := t.tracer.Start(ctx, "tracedTx.Verify", oteltrace.WithAttributes(
    27  		attribute.Stringer("txID", t.ID()),
    28  	))
    29  	defer span.End()
    30  
    31  	return t.Tx.Verify(ctx)
    32  }
    33  
    34  func (t *tracedTx) Accept(ctx context.Context) error {
    35  	ctx, span := t.tracer.Start(ctx, "tracedTx.Accept", oteltrace.WithAttributes(
    36  		attribute.Stringer("txID", t.ID()),
    37  	))
    38  	defer span.End()
    39  
    40  	return t.Tx.Accept(ctx)
    41  }
    42  
    43  func (t *tracedTx) Reject(ctx context.Context) error {
    44  	ctx, span := t.tracer.Start(ctx, "tracedTx.Reject", oteltrace.WithAttributes(
    45  		attribute.Stringer("txID", t.ID()),
    46  	))
    47  	defer span.End()
    48  
    49  	return t.Tx.Reject(ctx)
    50  }