/
type.go
38 lines (30 loc) · 892 Bytes
/
type.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package types
import (
"github.com/ProtoconNet/mitum-currency/v3/common"
"github.com/ProtoconNet/mitum2/base"
)
type GetNewProcessor func(
height base.Height,
getStateFunc base.GetStateFunc,
newPreProcessConstraintFunc base.NewOperationProcessorProcessFunc,
newProcessConstraintFunc base.NewOperationProcessorProcessFunc) (base.OperationProcessor, error)
type DuplicationType string
type AddFee map[CurrencyID][2]common.Big
func (af AddFee) Fee(key CurrencyID, fee common.Big) AddFee {
switch v, found := af[key]; {
case !found:
af[key] = [2]common.Big{common.ZeroBig, fee}
default:
af[key] = [2]common.Big{v[0], v[1].Add(fee)}
}
return af
}
func (af AddFee) Add(key CurrencyID, add common.Big) AddFee {
switch v, found := af[key]; {
case !found:
af[key] = [2]common.Big{add, common.ZeroBig}
default:
af[key] = [2]common.Big{v[0].Add(add), v[1]}
}
return af
}