[#197] sdk: Rename getters of Checksum type

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-11-16 11:21:28 +03:00 committed by Alex Vanin
parent 2afc684313
commit 9f0bc50e53
2 changed files with 9 additions and 9 deletions

View file

@ -37,8 +37,8 @@ func NewChecksum() *Checksum {
return NewChecksumFromV2(new(refs.Checksum))
}
// GetType returns checksum type.
func (c *Checksum) GetType() ChecksumType {
// Type returns checksum type.
func (c *Checksum) Type() ChecksumType {
switch (*refs.Checksum)(c).GetType() {
case refs.SHA256:
return ChecksumSHA256
@ -49,8 +49,8 @@ func (c *Checksum) GetType() ChecksumType {
}
}
// GetSum returns checksum bytes.
func (c *Checksum) GetSum() []byte {
// Sum returns checksum bytes.
func (c *Checksum) Sum() []byte {
return (*refs.Checksum)(c).GetSum()
}
@ -75,7 +75,7 @@ func (c *Checksum) ToV2() *refs.Checksum {
}
func EqualChecksums(cs1, cs2 *Checksum) bool {
return cs1.GetType() == cs2.GetType() && bytes.Equal(cs1.GetSum(), cs2.GetSum())
return cs1.Type() == cs2.Type() && bytes.Equal(cs1.Sum(), cs2.Sum())
}
// Marshal marshals Checksum into a protobuf binary form.

View file

@ -25,8 +25,8 @@ func TestChecksum(t *testing.T) {
c.SetSHA256(cSHA256)
require.Equal(t, ChecksumSHA256, c.GetType())
require.Equal(t, cSHA256[:], c.GetSum())
require.Equal(t, ChecksumSHA256, c.Type())
require.Equal(t, cSHA256[:], c.Sum())
cV2 := c.ToV2()
@ -38,8 +38,8 @@ func TestChecksum(t *testing.T) {
c.SetTillichZemor(cTZ)
require.Equal(t, ChecksumTZ, c.GetType())
require.Equal(t, cTZ[:], c.GetSum())
require.Equal(t, ChecksumTZ, c.Type())
require.Equal(t, cTZ[:], c.Sum())
cV2 = c.ToV2()