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

     1  // Copyright (c) 2020-2021 Blockwatch Data Inc.
     2  // Author: alex@blockwatch.cc
     3  
     4  package rpc
     5  
     6  import (
     7  	"github.com/mavryk-network/mvgo/mavryk"
     8  	"github.com/mavryk-network/mvgo/micheline"
     9  )
    10  
    11  // Ensure ConstantRegistration implements the TypedOperation interface.
    12  var _ TypedOperation = (*ConstantRegistration)(nil)
    13  
    14  // ConstantRegistration represents a global constant registration operation
    15  type ConstantRegistration struct {
    16  	Manager
    17  	Value micheline.Prim `json:"value,omitempty"`
    18  }
    19  
    20  // Costs returns operation cost to implement TypedOperation interface.
    21  func (c ConstantRegistration) Costs() mavryk.Costs {
    22  	res := c.Metadata.Result
    23  	burn := res.BalanceUpdates[0].Amount()
    24  	return mavryk.Costs{
    25  		Fee:         c.Manager.Fee,
    26  		GasUsed:     res.Gas(),
    27  		Burn:        -burn,
    28  		StorageUsed: res.StorageSize,
    29  		StorageBurn: -burn,
    30  	}
    31  }