@@ -18,7 +18,6 @@ var ErrIncorrectCreditCount = errors.New("incorrect credit count")
1818
1919type BondCaller interface {
2020 GetCredits (context.Context , rpcblock.Block , ... common.Address ) ([]* big.Int , error )
21- GetRequiredBonds (context.Context , rpcblock.Block , ... * big.Int ) ([]* big.Int , error )
2221}
2322
2423type BondEnricher struct {}
@@ -28,16 +27,6 @@ func NewBondEnricher() *BondEnricher {
2827}
2928
3029func (b * BondEnricher ) Enrich (ctx context.Context , block rpcblock.Block , caller GameCaller , game * monTypes.EnrichedGameData ) error {
31- if err := b .enrichCredits (ctx , block , caller , game ); err != nil {
32- return err
33- }
34- if err := b .enrichRequiredBonds (ctx , block , caller , game ); err != nil {
35- return err
36- }
37- return nil
38- }
39-
40- func (b * BondEnricher ) enrichCredits (ctx context.Context , block rpcblock.Block , caller GameCaller , game * monTypes.EnrichedGameData ) error {
4130 recipients := make (map [common.Address ]bool )
4231 for _ , claim := range game .Claims {
4332 if claim .CounteredBy != (common.Address {}) {
@@ -60,33 +49,3 @@ func (b *BondEnricher) enrichCredits(ctx context.Context, block rpcblock.Block,
6049 }
6150 return nil
6251}
63-
64- func (b * BondEnricher ) enrichRequiredBonds (ctx context.Context , block rpcblock.Block , caller GameCaller , game * monTypes.EnrichedGameData ) error {
65- positions := make ([]* big.Int , len (game .Claims ))
66- for _ , claim := range game .Claims {
67- // If the claim is not resolved, we don't need to get the bond
68- // for it since the Bond field in the claim will be accurate.
69- if ! claim .Resolved {
70- continue
71- }
72- positions = append (positions , claim .Position .ToGIndex ())
73- }
74- bonds , err := caller .GetRequiredBonds (ctx , block , positions ... )
75- if err != nil {
76- return err
77- }
78- if len (bonds ) != len (positions ) {
79- return fmt .Errorf ("%w, requested %v values but got %v" , ErrIncorrectCreditCount , len (positions ), len (bonds ))
80- }
81- game .RequiredBonds = make (map [int ]* big.Int )
82- bondIndex := 0
83- for i , claim := range game .Claims {
84- if ! claim .Resolved {
85- game .RequiredBonds [i ] = claim .Bond
86- continue
87- }
88- game .RequiredBonds [i ] = bonds [bondIndex ]
89- bondIndex ++
90- }
91- return nil
92- }
0 commit comments