also refer to adjusted balance for rpc

This commit is contained in:
Cassandra Heart 2024-01-03 02:13:51 -06:00
parent 8899ccd864
commit d02ef18174
No known key found for this signature in database
GPG Key ID: 6352152859385958

View File

@ -226,6 +226,12 @@ func (r *RPCServer) GetTokenInfo(
return nil, errors.Wrap(err, "get token info") return nil, errors.Wrap(err, "get token info")
} }
peerBytes := r.pubSub.GetPeerID()
peerAddr, err := poseidon.HashBytes(peerBytes)
if err != nil {
panic(err)
}
addr, err := poseidon.HashBytes(provingKey.PublicKey) addr, err := poseidon.HashBytes(provingKey.PublicKey)
if err != nil { if err != nil {
panic(err) panic(err)
@ -234,6 +240,9 @@ func (r *RPCServer) GetTokenInfo(
addrBytes := addr.Bytes() addrBytes := addr.Bytes()
addrBytes = append(make([]byte, 32-len(addrBytes)), addrBytes...) addrBytes = append(make([]byte, 32-len(addrBytes)), addrBytes...)
peerAddrBytes := peerAddr.Bytes()
peerAddrBytes = append(make([]byte, 32-len(peerAddrBytes)), peerAddrBytes...)
frame, err := r.clockStore.GetLatestDataClockFrame( frame, err := r.clockStore.GetLatestDataClockFrame(
append( append(
p2p.GetBloomFilter(application.CEREMONY_ADDRESS, 256, 3), p2p.GetBloomFilter(application.CEREMONY_ADDRESS, 256, 3),
@ -303,6 +312,15 @@ func (r *RPCServer) GetTokenInfo(
new(big.Int).SetUint64(child.External.Total), new(big.Int).SetUint64(child.External.Total),
) )
} }
if bytes.Equal(
child.External.Key,
peerAddrBytes,
) {
ownedTotal = ownedTotal.Add(
ownedTotal,
new(big.Int).SetUint64(child.External.Total),
)
}
} }
} }
} }