state: implement SignedDataSource on ChangeStateRequest message

This commit is contained in:
Leonard Lyubich 2020-05-11 16:31:39 +03:00
parent 5545b25a95
commit ab198b4049
4 changed files with 89 additions and 0 deletions

24
state/types.go Normal file
View file

@ -0,0 +1,24 @@
package state
import (
"encoding/binary"
)
// SetState is a State field setter.
func (m *ChangeStateRequest) SetState(st ChangeStateRequest_State) {
m.State = st
}
// Size returns the size of the state binary representation.
func (ChangeStateRequest_State) Size() int {
return 4
}
// Bytes returns the state binary representation.
func (x ChangeStateRequest_State) Bytes() []byte {
data := make([]byte, x.Size())
binary.BigEndian.PutUint32(data, uint32(x))
return data
}