github.com/MetalBlockchain/metalgo@v1.11.9/vms/components/avax/utxo_handler.go (about)

     1  // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
     2  // See the file LICENSE for licensing terms.
     3  
     4  package avax
     5  
     6  import "github.com/MetalBlockchain/metalgo/ids"
     7  
     8  // Removes the UTXOs consumed by [ins] from the UTXO set
     9  func Consume(utxoDB UTXODeleter, ins []*TransferableInput) {
    10  	for _, input := range ins {
    11  		utxoDB.DeleteUTXO(input.InputID())
    12  	}
    13  }
    14  
    15  // Adds the UTXOs created by [outs] to the UTXO set.
    16  // [txID] is the ID of the tx that created [outs].
    17  func Produce(
    18  	utxoDB UTXOAdder,
    19  	txID ids.ID,
    20  	outs []*TransferableOutput,
    21  ) {
    22  	for index, out := range outs {
    23  		utxoDB.AddUTXO(&UTXO{
    24  			UTXOID: UTXOID{
    25  				TxID:        txID,
    26  				OutputIndex: uint32(index),
    27  			},
    28  			Asset: out.Asset,
    29  			Out:   out.Output(),
    30  		})
    31  	}
    32  }