github.com/mavryk-network/mvgo@v1.19.9/rpc/doublebaking.go (about) 1 // Copyright (c) 2020-2022 Blockwatch Data Inc. 2 // Author: alex@blockwatch.cc 3 4 package rpc 5 6 import "github.com/mavryk-network/mvgo/mavryk" 7 8 // Ensure DoubleBaking implements the TypedOperation interface. 9 var _ TypedOperation = (*DoubleBaking)(nil) 10 11 // DoubleBaking represents a double_baking_evidence operation 12 type DoubleBaking struct { 13 Generic 14 BH1 BlockHeader `json:"bh1"` 15 BH2 BlockHeader `json:"bh2"` 16 } 17 18 // Costs returns operation cost to implement TypedOperation interface. 19 func (d DoubleBaking) Costs() mavryk.Costs { 20 var burn int64 21 upd := d.Metadata.BalanceUpdates 22 // last item is accuser reward, rest is burned 23 for i, v := range upd { 24 if i == len(upd)-1 { 25 burn -= v.Amount() 26 } else { 27 burn += v.Amount() 28 } 29 } 30 return mavryk.Costs{ 31 Burn: -burn, 32 } 33 }