forked from stellar/go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinflation.go
36 lines (31 loc) · 816 Bytes
/
inflation.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
package build
import (
"github.com/stellar/go/support/errors"
"github.com/stellar/go/xdr"
)
// Inflation groups the creation of a new InflationBuilder with a call to Mutate.
func Inflation(muts ...interface{}) (result InflationBuilder) {
result.Mutate(muts...)
return
}
// InflationBuilder represents an operation that is being built.
type InflationBuilder struct {
O xdr.Operation
Err error
}
// Mutate applies the provided mutators to this builder's operation.
func (b *InflationBuilder) Mutate(muts ...interface{}) {
for _, m := range muts {
var err error
switch mut := m.(type) {
case OperationMutator:
err = mut.MutateOperation(&b.O)
default:
err = errors.New("Mutator type not allowed")
}
if err != nil {
b.Err = errors.Wrap(err, "InflationBuilder error")
return
}
}
}