本文整理匯總了Golang中github.com/FactomProject/factomd/common/primitives.NewTimestampNow函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewTimestampNow函數的具體用法?Golang NewTimestampNow怎麽用?Golang NewTimestampNow使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了NewTimestampNow函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: listen
func listen() {
prtone := false
for {
msg, err := p2pProxy.Recieve()
if err != nil || msg == nil {
if !prtone {
if err != nil {
fmt.Println(err.Error())
}
}
prtone = true
time.Sleep(1 * time.Millisecond)
continue
}
time.Sleep(1 * time.Millisecond)
if old[msg.GetHash().Fixed()] == nil {
prtone = false
old[msg.GetHash().Fixed()] = msg
bounce, ok := msg.(*messages.Bounce)
if ok && len(bounce.Stamps) < 100 {
bounce.Stamps = append(bounce.Stamps, primitives.NewTimestampNow())
p2pProxy.Send(msg)
fmt.Println(msg.String())
}
bounces++
} else {
oldcnt++
}
}
}
示例2: newAddServer
func newAddServer() *AddServerMsg {
addserv := new(AddServerMsg)
addserv.Timestamp = primitives.NewTimestampNow()
addserv.ServerChainID = primitives.Sha([]byte("FNode0"))
addserv.ServerType = 0
return addserv
}
示例3: String
func (m *BounceReply) String() string {
// bbbb Origin: 2016-09-05 12:26:20.426954586 -0500 CDT left BounceReply Start: 2016-09-05 12:26:05 Hops: 1 Size: 43 Last Hop Took 14.955 Average Hop: 14.955
now := time.Now()
t := fmt.Sprintf("%2d:%2d:%2d.%03d", now.Hour(), now.Minute(), now.Second(), now.Nanosecond()/1000000)
mill := m.Timestamp.GetTimeMilli()
mills := mill % 1000
mill = mill / 1000
secs := mill % 60
mill = mill / 60
mins := mill % 60
mill = mill / 60
hrs := mill % 24
t2 := fmt.Sprintf("%2d:%2d:%2d.%03d", hrs, mins, secs, mills)
str := fmt.Sprintf("Origin: %12s %10s-%03d-%03d BounceReply Start: %12s Hops: %5d Size: %5d ",
t,
strings.TrimSpace(m.Name),
m.Number,
len(m.Stamps),
t2,
len(m.Stamps), m.SizeOf())
elapse := primitives.NewTimestampNow().GetTimeMilli() - m.Stamps[len(m.Stamps)-1].GetTimeMilli()
str = str + fmt.Sprintf("Last Hop Took %d.%03d", elapse/1000, elapse%1000)
return str
}
示例4: String
func (m *Bounce) String() string {
// bbbb Origin: 2016-09-05 12:26:20.426954586 -0500 CDT left Bounce Start: 2016-09-05 12:26:05 Hops: 1 Size: 43 Last Hop Took 14.955 Average Hop: 14.955
now := time.Now()
t := fmt.Sprintf("%2d:%02d:%02d.%03d", now.Hour(), now.Minute(), now.Second(), now.Nanosecond()/1000000)
mill := m.Timestamp.GetTimeMilli()
mills := mill % 1000
mill = mill / 1000
secs := mill % 60
mill = mill / 60
mins := mill % 60
mill = mill / 60
hrs := mill % 24
t2 := fmt.Sprintf("%2d:%2d:%2d.%03d", hrs, mins, secs, mills)
str := fmt.Sprintf("Origin: %12s %30s-%03d-%03d Bounce Start: %12s Hops: %5d Size: %5d ",
t,
strings.TrimSpace(m.Name),
m.Number,
len(m.Stamps),
t2,
len(m.Stamps), m.SizeOf())
var sum int64
for i := 0; i < len(m.Stamps)-1; i++ {
sum += m.Stamps[i+1].GetTimeMilli() - m.Stamps[i].GetTimeMilli()
}
elapse := primitives.NewTimestampNow().GetTimeMilli() - m.Stamps[len(m.Stamps)-1].GetTimeMilli()
sum += elapse
sign := " "
if sum < 0 {
sign = "-"
sum = sum * -1
}
avg := sum / (int64(len(m.Stamps)))
str = str + fmt.Sprintf("Last Hop Took %3d.%03d Average Hop: %s%3d.%03d Hash: %x", elapse/1000, elapse%1000, sign, avg/1000, avg%1000, m.GetHash().Bytes()[:4])
return str
}
示例5: checkMissingDirBlockInfo
func (a *Anchor) checkMissingDirBlockInfo() {
anchorLog.Debug("checkMissingDirBlockInfo for those unsaved DirBlocks in database")
dblocks, _ := a.db.FetchAllDBlocks()
dirBlockInfos, _ := a.db.FetchAllDirBlockInfos() //FetchAllDirBlockInfos()
for _, dblock := range dblocks {
var found = false
for i, dbinfo := range dirBlockInfos {
if dbinfo.GetDatabaseHeight() == dblock.GetDatabaseHeight() {
dirBlockInfos = append(dirBlockInfos[:i], dirBlockInfos[i+1:]...)
found = true
break
}
}
if !found {
if dblock.GetKeyMR() == nil || bytes.Compare(dblock.GetKeyMR().Bytes(), primitives.NewZeroHash().Bytes()) == 0 {
dblock.BuildKeyMerkleRoot()
}
dirBlockInfo := dbInfo.NewDirBlockInfoFromDirBlock(dblock)
dirBlockInfo.SetTimestamp(primitives.NewTimestampNow())
anchorLog.Debug("add missing dirBlockInfo to map: ", spew.Sdump(dirBlockInfo))
a.db.SaveDirBlockInfo(dirBlockInfo)
a.dirBlockInfoSlice = append(a.dirBlockInfoSlice, dirBlockInfo)
}
}
}
示例6: newAck
func newAck() *Ack {
ack := new(Ack)
ack.Timestamp = primitives.NewTimestampNow()
hash, err := primitives.NewShaHashFromStr("cbd3d09db6defdc25dfc7d57f3479b339a077183cd67022e6d1ef6c041522b40")
if err != nil {
panic(err)
}
ack.MessageHash = hash
hash, err = primitives.NewShaHashFromStr("bbd3d09db6defdc25dfc7d57f3479b339a077183cd67022e6d1ef6c041522b40")
if err != nil {
panic(err)
}
ack.MessageHash = hash
ack.DBHeight = 123
ack.Height = 456
hash, err = primitives.NewShaHashFromStr("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
if err != nil {
panic(err)
}
ack.SerialHash = hash
hash, err = primitives.NewShaHashFromStr("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")
if err != nil {
panic(err)
}
ack.LeaderChainID = hash
return ack
}
示例7: TestMarshalUnmarshalServerFault
func TestMarshalUnmarshalServerFault(t *testing.T) {
ts := primitives.NewTimestampNow()
vmIndex := int(*ts) % 10
sf := NewServerFault(primitives.NewHash([]byte("a test")), primitives.NewHash([]byte("a test2")), vmIndex, 10, 100, 0, ts)
hex, err := sf.MarshalBinary()
if err != nil {
t.Error(err)
}
t.Logf("Marshalled - %x", hex)
sf2, err := UnmarshalMessage(hex)
if err != nil {
t.Error(err)
}
str := sf2.String()
t.Logf("str - %v", str)
if sf2.Type() != constants.FED_SERVER_FAULT_MSG {
t.Errorf("Invalid message type unmarshalled - got %v, expected %v", sf2.Type(), constants.FED_SERVER_FAULT_MSG)
}
hex2, err := sf2.(*ServerFault).MarshalBinary()
if err != nil {
t.Error(err)
}
if len(hex) != len(hex2) {
t.Error("Hexes aren't of identical length")
}
for i := range hex {
if hex[i] != hex2[i] {
t.Error("Hexes do not match")
}
}
}
示例8: newDBStateMissing
func newDBStateMissing() *DBStateMissing {
msg := new(DBStateMissing)
msg.Timestamp = primitives.NewTimestampNow()
msg.DBHeightStart = 0x01234567
msg.DBHeightEnd = 0x89012345
return msg
}
示例9: newDataResponseEntry
func newDataResponseEntry() *DataResponse {
dr := new(DataResponse)
dr.Timestamp = primitives.NewTimestampNow()
dr.DataType = 0
entry := testHelper.CreateFirstTestEntry()
dr.DataObject = entry
dr.DataHash = entry.GetHash()
return dr
}
示例10: newDataResponseEntryBlock
func newDataResponseEntryBlock() *DataResponse {
dr := new(DataResponse)
dr.Timestamp = primitives.NewTimestampNow()
dr.DataType = 1
entry, _ := testHelper.CreateTestEntryBlock(nil)
dr.DataObject = entry
dr.DataHash, _ = entry.KeyMR()
return dr
}
示例11: newMissingMsg
func newMissingMsg() *MissingMsg {
msg := new(MissingMsg)
msg.Timestamp = primitives.NewTimestampNow()
msg.Asking = primitives.NewZeroHash()
msg.DBHeight = 0x12345678
msg.ProcessListHeight = append(msg.ProcessListHeight, 0x98765432)
return msg
}
示例12: newChangeServerKey
func newChangeServerKey() *ChangeServerKeyMsg {
addserv := new(ChangeServerKeyMsg)
addserv.Timestamp = primitives.NewTimestampNow()
addserv.IdentityChainID = primitives.Sha([]byte("FNode0"))
addserv.AdminBlockChange = 0
addserv.KeyPriority = 0
addserv.KeyType = 0
addserv.Key = primitives.Sha([]byte("A_Key"))
return addserv
}
示例13: newMissingData
func newMissingData() *MissingData {
msg := new(MissingData)
msg.Timestamp = primitives.NewTimestampNow()
h, err := primitives.NewShaHashFromStr("deadbeef00000000000000000000000000000000000000000000000000000000")
if err != nil {
panic(err)
}
msg.RequestHash = h
return msg
}
示例14: main
func main() {
InitNetwork()
time.Sleep(1 * time.Second)
fmt.Println("Starting...")
go listen()
for {
bounce := new(messages.Bounce)
bounce.Number = cntreq
cntreq++
bounce.Name = name
bounce.Timestamp = primitives.NewTimestampNow()
bounce.Stamps = append(bounce.Stamps, primitives.NewTimestampNow())
if isp2p {
bounce.SetPeer2Peer(true)
p2pRequestSent++
} else {
broadcastSent++
}
p2pProxy.Send(bounce)
SetMsg(bounce)
if isp2p {
fmt.Printf("netTest(%s): ::p2p:: request sent: %d request recieved %d sent: %d received: %d\n",
name,
p2pRequestSent, p2pRequestReceived,
p2pSent, p2pReceived)
} else {
fmt.Printf("netTest(%s): ::: broadcast sent: %d broadcast received: %d\n",
name,
broadcastSent, broadcastReceived)
}
time.Sleep(8 * time.Second)
}
}
示例15: TestThatFullAndFaultCoreHashesMatch
func TestThatFullAndFaultCoreHashesMatch(t *testing.T) {
ts := primitives.NewTimestampNow()
vmIndex := int(*ts) % 10
sf := NewServerFault(primitives.NewHash([]byte("a test")), primitives.NewHash([]byte("a test2")), vmIndex, 10, 100, 0, ts)
sl := coupleOfSigs(t)
fsf := NewFullServerFault(nil, sf, sl, 0)
if !sf.GetCoreHash().IsSameAs(fsf.GetCoreHash()) {
t.Error("CoreHashes do not match between FullServerFault and ServerFault")
}
}