Commit 2e26cca3 authored by duanjinfei's avatar duanjinfei

update time convert byte

parent 44c177e8
...@@ -2,7 +2,6 @@ package nm ...@@ -2,7 +2,6 @@ package nm
import ( import (
"bytes" "bytes"
"encoding/binary"
"example.com/m/conf" "example.com/m/conf"
"example.com/m/log" "example.com/m/log"
"example.com/m/models" "example.com/m/models"
...@@ -12,6 +11,7 @@ import ( ...@@ -12,6 +11,7 @@ import (
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
nodemanagerV1 "github.com/odysseus/odysseus-protocol/gen/proto/go/nodemanager/v1" nodemanagerV1 "github.com/odysseus/odysseus-protocol/gen/proto/go/nodemanager/v1"
"github.com/shirou/gopsutil/cpu" "github.com/shirou/gopsutil/cpu"
"math/big"
"strconv" "strconv"
"time" "time"
) )
...@@ -131,12 +131,11 @@ func SubmitResourceMapRes(params ...interface{}) *nodemanagerV1.WorkerMessage { ...@@ -131,12 +131,11 @@ func SubmitResourceMapRes(params ...interface{}) *nodemanagerV1.WorkerMessage {
func RegisterInfoResp(params ...interface{}) *nodemanagerV1.WorkerMessage { func RegisterInfoResp(params ...interface{}) *nodemanagerV1.WorkerMessage {
log.Info("Register info response received params:", params) log.Info("Register info response received params:", params)
nowTimeStamp := time.Now().Unix() nowTimeStamp := time.Now().Unix()
byteSlice := make([]byte, 8) nowTimeBytes := big.NewInt(nowTimeStamp).Bytes()
binary.BigEndian.PutUint64(byteSlice, uint64(nowTimeStamp))
signHash := crypto.Keccak256Hash(bytes.NewBufferString(conf.GetConfig().GetExternalIp()).Bytes(), signHash := crypto.Keccak256Hash(bytes.NewBufferString(conf.GetConfig().GetExternalIp()).Bytes(),
bytes.NewBufferString(conf.GetConfig().SignPub).Bytes(), bytes.NewBufferString(conf.GetConfig().SignPub).Bytes(),
bytes.NewBufferString(conf.GetConfig().BenefitAddress).Bytes(), bytes.NewBufferString(conf.GetConfig().BenefitAddress).Bytes(),
byteSlice) nowTimeBytes)
log.WithField("hash", signHash.String()).Info("register message sign result") log.WithField("hash", signHash.String()).Info("register message sign result")
sign, _ := crypto.Sign(signHash.Bytes(), conf.GetConfig().SignPrivateKey) sign, _ := crypto.Sign(signHash.Bytes(), conf.GetConfig().SignPrivateKey)
log.Info("register message sign:", common.Bytes2Hex(sign)) log.Info("register message sign:", common.Bytes2Hex(sign))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment