types: add PriceVolume.Equals method

This commit is contained in:
c9s 2023-07-05 15:30:08 +08:00
parent 1ad10a9360
commit fbc49c28ef
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -12,6 +12,10 @@ type PriceVolume struct {
Price, Volume fixedpoint.Value
}
func (p PriceVolume) Equals(b PriceVolume) bool {
return p.Price.Eq(b.Price) && p.Volume.Eq(b.Volume)
}
func (p PriceVolume) String() string {
return fmt.Sprintf("PriceVolume{ price: %s, volume: %s }", p.Price.String(), p.Volume.String())
}
@ -140,7 +144,6 @@ func (slice *PriceVolumeSlice) UnmarshalJSON(b []byte) error {
// ParsePriceVolumeSliceJSON tries to parse a 2 dimensional string array into a PriceVolumeSlice
//
// [["9000", "10"], ["9900", "10"], ... ]
//
func ParsePriceVolumeSliceJSON(b []byte) (slice PriceVolumeSlice, err error) {
var as [][]fixedpoint.Value