tweaking
--HG-- branch : dev
This commit is contained in:
parent
79c4bc2e47
commit
3051e6fe4b
@ -46,15 +46,14 @@ func decodeJob(data []byte) (job *Job, err error) {
|
|||||||
// Encode a job to byte slice
|
// Encode a job to byte slice
|
||||||
func (job *Job) Encode() (data []byte) {
|
func (job *Job) Encode() (data []byte) {
|
||||||
l := len(job.Data)
|
l := len(job.Data)
|
||||||
tl := l
|
|
||||||
if job.Handle != "" {
|
if job.Handle != "" {
|
||||||
tl += len(job.Handle) + 1
|
l += len(job.Handle) + 1
|
||||||
}
|
}
|
||||||
data = make([]byte, 0, tl + 12)
|
data = make([]byte, 0, l + 12)
|
||||||
|
|
||||||
magiccode := common.Uint32ToBytes(job.magicCode)
|
magiccode := common.Uint32ToBytes(job.magicCode)
|
||||||
datatype := common.Uint32ToBytes(job.DataType)
|
datatype := common.Uint32ToBytes(job.DataType)
|
||||||
datalength := common.Uint32ToBytes(uint32(tl))
|
datalength := common.Uint32ToBytes(uint32(l))
|
||||||
|
|
||||||
data = append(data, magiccode[:]...)
|
data = append(data, magiccode[:]...)
|
||||||
data = append(data, datatype[:]...)
|
data = append(data, datatype[:]...)
|
||||||
|
Loading…
Reference in New Issue
Block a user