@@ -330,11 +330,11 @@ func (i *Info) Uptime(_ *http.Request, _ *struct{}, reply *UptimeResponse) error
330330}
331331
332332type ACP struct {
333- SupportWeight * big. Int `json:"supportWeight"`
333+ SupportWeight json. BigInt `json:"supportWeight"`
334334 Supporters set.Set [ids.NodeID ] `json:"supporters"`
335- ObjectWeight * big. Int `json:"objectWeight"`
335+ ObjectWeight json. BigInt `json:"objectWeight"`
336336 Objectors set.Set [ids.NodeID ] `json:"objectors"`
337- AbstainWeight * big. Int `json:"abstainWeight"`
337+ AbstainWeight json. BigInt `json:"abstainWeight"`
338338}
339339
340340type ACPsReply struct {
@@ -344,7 +344,11 @@ type ACPsReply struct {
344344func (a * ACPsReply ) getACP (acpNum uint32 ) * ACP {
345345 acp , ok := a .ACPs [acpNum ]
346346 if ! ok {
347- acp = & ACP {}
347+ acp = & ACP {
348+ SupportWeight : json .NewBigIntFromInt (0 ),
349+ ObjectWeight : json .NewBigIntFromInt (0 ),
350+ AbstainWeight : json .NewBigIntFromInt (0 ),
351+ }
348352 a .ACPs [acpNum ] = acp
349353 }
350354 return acp
@@ -367,19 +371,19 @@ func (i *Info) Acps(_ *http.Request, _ *struct{}, reply *ACPsReply) error {
367371 for acpNum := range peer .SupportedACPs {
368372 acp := reply .getACP (acpNum )
369373 acp .Supporters .Add (peer .ID )
370- acp .SupportWeight = new (big.Int ).Add (acp .SupportWeight , new (big.Int ).SetUint64 (weight ))
374+ acp .SupportWeight . Set ( new (big.Int ).Add (acp .SupportWeight . ToBigInt () , new (big.Int ).SetUint64 (weight ) ))
371375 }
372376 for acpNum := range peer .ObjectedACPs {
373377 acp := reply .getACP (acpNum )
374378 acp .Objectors .Add (peer .ID )
375- acp .ObjectWeight = new (big.Int ).Add (acp .ObjectWeight , new (big.Int ).SetUint64 (weight ))
379+ acp .ObjectWeight . Set ( new (big.Int ).Add (acp .ObjectWeight . ToBigInt () , new (big.Int ).SetUint64 (weight ) ))
376380 }
377381 }
378382
379383 totalWeight := i .validators .TotalWeight (constants .PrimaryNetworkID )
380384 for acpNum := range constants .CurrentACPs {
381385 acp := reply .getACP (acpNum )
382- acp .AbstainWeight = new (big.Int ).Sub (totalWeight , new (big.Int ).Add (acp .SupportWeight , acp .ObjectWeight ))
386+ acp .AbstainWeight . Set ( new (big.Int ).Sub (totalWeight , new (big.Int ).Add (acp .SupportWeight . ToBigInt () , acp .ObjectWeight . ToBigInt ()) ))
383387 }
384388 return nil
385389}
0 commit comments