本文整理匯總了Golang中github.com/FactomProject/factomd/common/interfaces.IState.GetTimestamp方法的典型用法代碼示例。如果您正苦於以下問題:Golang IState.GetTimestamp方法的具體用法?Golang IState.GetTimestamp怎麽用?Golang IState.GetTimestamp使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/FactomProject/factomd/common/interfaces.IState
的用法示例。
在下文中一共展示了IState.GetTimestamp方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: HandleV2RevealEntry
func HandleV2RevealEntry(state interfaces.IState, params interface{}) (interface{}, *primitives.JSONError) {
e := new(EntryRequest)
err := MapToObject(params, e)
if err != nil {
return nil, NewInvalidParamsError()
}
entry := entryBlock.NewEntry()
if p, err := hex.DecodeString(e.Entry); err != nil {
return nil, NewInvalidEntryError()
} else {
_, err := entry.UnmarshalBinaryData(p)
if err != nil {
return nil, NewInvalidEntryError()
}
}
msg := new(messages.RevealEntryMsg)
msg.Entry = entry
msg.Timestamp = state.GetTimestamp()
state.APIQueue() <- msg
resp := new(RevealEntryResponse)
resp.Message = "Entry Reveal Success"
resp.EntryHash = entry.GetHash().String()
return resp, nil
}
示例2: PrtMsgs
func (m *MsgLog) PrtMsgs(state interfaces.IState) {
m.sem.Lock()
defer m.sem.Unlock()
if len(m.MsgList) == 0 {
return
}
fmt.Println(state.String())
fmt.Println("\n-----------------------------------------------------")
for _, e := range m.MsgList {
if e.valid {
dirstr := "->"
if !e.out {
dirstr = "<-"
}
fmt.Print(fmt.Sprintf("**** %8s %2s %8s %10s %5v **** %s\n", e.name, dirstr, e.peer, e.where, e.valid, e.msg.String()))
}
}
now := state.GetTimestamp()
m.last = now
m.msgCnt += len(m.MsgList) // Keep my counts
m.msgCntp += len(m.MsgList)
m.MsgList = m.MsgList[0:0] // Once printed, clear the list
fmt.Println(fmt.Sprintf("*** %42s **** ", fmt.Sprintf("Length: %d Msgs/sec: T %d P %d", len(m.MsgList), m.msgPerSec, m.msgPerSecp)))
fmt.Println("\n-----------------------------------------------------")
}
示例3: NewAck
// Create a new Acknowledgement. This Acknowledgement
func NewAck(state interfaces.IState, hash interfaces.IHash) (iack interfaces.IMsg, err error) {
var last *Ack
if state.GetLastAck() != nil {
last = state.GetLastAck().(*Ack)
}
ack := new(Ack)
ack.Timestamp = state.GetTimestamp()
ack.MessageHash = hash
if last == nil {
ack.Height = 0
ack.SerialHash = ack.MessageHash
} else {
ack.Height = last.Height + 1
ack.SerialHash, err = primitives.CreateHash(last.MessageHash, ack.MessageHash)
if err != nil {
return nil, err
}
}
state.SetLastAck(ack)
// TODO: Add the signature.
return ack, nil
}
示例4: NewEntryBlockResponse
func NewEntryBlockResponse(state interfaces.IState) interfaces.IMsg {
msg := new(EntryBlockResponse)
msg.Peer2Peer = true // Always a peer2peer request.
msg.Timestamp = state.GetTimestamp()
return msg
}
示例5: NewAddServerByHashMsg
func NewAddServerByHashMsg(state interfaces.IState, serverType int, newServerHash interfaces.IHash) interfaces.IMsg {
msg := new(AddServerMsg)
msg.ServerChainID = newServerHash
msg.ServerType = serverType
msg.Timestamp = state.GetTimestamp()
return msg
}
示例6: NewAddServerMsg
func NewAddServerMsg(state interfaces.IState, serverType int) interfaces.IMsg {
msg := new(AddServerMsg)
msg.ServerChainID = state.GetIdentityChainID()
msg.ServerType = serverType
msg.Timestamp = state.GetTimestamp()
return msg
}
示例7: NewRemoveServerMsg
func NewRemoveServerMsg(state interfaces.IState, chainId interfaces.IHash, serverType int) interfaces.IMsg {
msg := new(RemoveServerMsg)
msg.ServerChainID = chainId
msg.ServerType = serverType
msg.Timestamp = state.GetTimestamp()
return msg
}
示例8: NewDBStateMissing
func NewDBStateMissing(state interfaces.IState, dbheightStart uint32, dbheightEnd uint32) interfaces.IMsg {
msg := new(DBStateMissing)
msg.Peer2Peer = true // Always a peer2peer request.
msg.Timestamp = state.GetTimestamp()
msg.DBHeightStart = dbheightStart
msg.DBHeightEnd = dbheightEnd
return msg
}
示例9: Expire
// Try and Resend. Return true if we should keep the message, false if we should give up.
func (m *MessageBase) Expire(s interfaces.IState) (rtn bool) {
now := s.GetTimestamp().GetTimeMilli()
if m.expire == 0 {
m.expire = now
}
if now-m.expire > 5*60*1000 { // Keep messages for some length before giving up.
rtn = true
}
return
}
示例10: NewMissingData
func NewMissingData(state interfaces.IState, requestHash interfaces.IHash) interfaces.IMsg {
msg := new(MissingData)
msg.Peer2Peer = true // Always a peer2peer request.
msg.Timestamp = state.GetTimestamp()
msg.RequestHash = requestHash
return msg
}
示例11: NewMissingMsgResponse
func NewMissingMsgResponse(state interfaces.IState, msgResponse interfaces.IMsg, ackResponse interfaces.IMsg) interfaces.IMsg {
msg := new(MissingMsgResponse)
msg.Peer2Peer = true // Always a peer2peer request.
msg.Timestamp = state.GetTimestamp()
msg.MsgResponse = msgResponse
msg.AckResponse = ackResponse
return msg
}
示例12: Resend
// Try and Resend. Return true if we should keep the message, false if we should give up.
func (m *MessageBase) Resend(s interfaces.IState) (rtn bool) {
now := s.GetTimestamp().GetTimeMilli()
if m.resend == 0 {
m.resend = now
return false
}
if now-m.resend > 10000 && len(s.NetworkOutMsgQueue()) < 1000 { // Resend every second
m.resend = now
return true
}
return false
}
示例13: NewChangeServerKeyMsg
func NewChangeServerKeyMsg(state interfaces.IState, identityChain interfaces.IHash, adminChange byte, keyPriority byte, keyType byte, key interfaces.IHash) interfaces.IMsg {
msg := new(ChangeServerKeyMsg)
msg.IdentityChainID = identityChain
msg.AdminBlockChange = adminChange
msg.KeyType = keyType
msg.KeyPriority = keyPriority
msg.Key = key
msg.Timestamp = state.GetTimestamp()
return msg
}
示例14: NewMissingMsg
// NewMissingMsg: Build a missing Message request, and add the first Height
func NewMissingMsg(state interfaces.IState, vm int, dbHeight uint32, processlistHeight uint32) *MissingMsg {
msg := new(MissingMsg)
msg.Asking = state.GetIdentityChainID()
msg.Peer2Peer = true // Always a peer2peer request // .
msg.VMIndex = vm
msg.Timestamp = state.GetTimestamp()
msg.DBHeight = dbHeight
msg.ProcessListHeight = append(msg.ProcessListHeight, processlistHeight)
msg.SystemHeight = uint32(state.GetSystemHeight(dbHeight))
return msg
}
示例15: Priority
func (m *FullServerFault) Priority(state interfaces.IState) (priority int64) {
now := state.GetTimestamp()
// After 20 seconds, a negotiation's priority is now zero.
if now.GetTimeSeconds()-m.Timestamp.GetTimeSeconds() < 20 {
return 0
}
// oldest timestamp is highest priority
priority = math.MaxInt64 - m.Timestamp.GetTime().UnixNano()
// Mask off lowest byte
priority = (priority | 0xFF) ^ 0xFF
// Add VMIndex
priority = priority + int64(m.VMIndex)
return
}