github.com/mavryk-network/mvgo@v1.19.9/mavryk/cost.go (about)

     1  // Copyright (c) 2020-2022 Blockwatch Data Inc.
     2  // Author: alex@blockwatch.cc
     3  
     4  package mavryk
     5  
     6  // Limits represents all resource limits defined for an operation in Tezos.
     7  type Limits struct {
     8  	Fee          int64
     9  	GasLimit     int64
    10  	StorageLimit int64
    11  }
    12  
    13  // Add adds two limits z = x + y and returns the sum z without changing any of the inputs.
    14  func (x Limits) Add(y Limits) Limits {
    15  	x.Fee += y.Fee
    16  	x.GasLimit += y.GasLimit
    17  	x.StorageLimit += y.StorageLimit
    18  	return x
    19  }
    20  
    21  // Costs represents all costs paid by an operation in Tezos. Its contents depends on
    22  // operation type and activity. Consensus and voting operations have no cost,
    23  // user operations have variable cost. For transactions with internal results costs
    24  // are a summary.
    25  type Costs struct {
    26  	Fee            int64 // the total fee paid in mumav
    27  	Burn           int64 // total amount of mumav burned (not included in fee)
    28  	GasUsed        int64 // gas used
    29  	StorageUsed    int64 // new storage bytes allocated
    30  	StorageBurn    int64 // mumav burned for allocating new storage (not included in fee)
    31  	AllocationBurn int64 // mumav burned for allocating a new account (not included in fee)
    32  }
    33  
    34  // Add adds two costs z = x + y and returns the sum z without changing any of the inputs.
    35  func (x Costs) Add(y Costs) Costs {
    36  	x.Fee += y.Fee
    37  	x.Burn += y.Burn
    38  	x.GasUsed += y.GasUsed
    39  	x.StorageUsed += y.StorageUsed
    40  	x.StorageBurn += y.StorageBurn
    41  	x.AllocationBurn += y.AllocationBurn
    42  	return x
    43  }