當前位置: 首頁>>代碼示例>>Golang>>正文


Golang IState.IncDBStateAnswerCnt方法代碼示例

本文整理匯總了Golang中github.com/FactomProject/factomd/common/interfaces.IState.IncDBStateAnswerCnt方法的典型用法代碼示例。如果您正苦於以下問題:Golang IState.IncDBStateAnswerCnt方法的具體用法?Golang IState.IncDBStateAnswerCnt怎麽用?Golang IState.IncDBStateAnswerCnt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/FactomProject/factomd/common/interfaces.IState的用法示例。


在下文中一共展示了IState.IncDBStateAnswerCnt方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: FollowerExecute

func (m *DBStateMissing) FollowerExecute(state interfaces.IState) {
	if len(state.NetworkOutMsgQueue()) > 1000 {
		return
	}

	// TODO: Likely need to consider a limit on how many blocks we reply with.  For now,
	// just give them what they ask for.
	start := m.DBHeightStart
	end := m.DBHeightEnd
	if end-start > 200 {
		end = start + 200
	}
	missingone := false
	for dbs := start; dbs <= end; dbs++ {
		msg, err := state.LoadDBState(dbs)
		if msg != nil && err == nil {
			if missingone {
				fmt.Println("dddd Missing some prior dbstates.  Start", start, "End", end, "Found ", dbs)
			}
			// If I don't have this block, ignore.
			msg.SetOrigin(m.GetOrigin())
			msg.SetNetworkOrigin(m.GetNetworkOrigin())
			msg.SendOut(state, msg)
			state.IncDBStateAnswerCnt()
		} else {
			missingone = true
		}
	}

	return
}
開發者ID:FactomProject,項目名稱:factomd,代碼行數:31,代碼來源:dbstateMissing.go

示例2: FollowerExecute

func (m *MissingEntryBlocks) FollowerExecute(state interfaces.IState) {
	if len(state.NetworkOutMsgQueue()) > 1000 {
		return
	}
	start := m.DBHeightStart
	end := m.DBHeightEnd
	if end-start > 20 {
		end = start + 20
	}
	db := state.GetAndLockDB()
	defer state.UnlockDB()

	resp := NewEntryBlockResponse(state).(*EntryBlockResponse)

	for i := start; i <= end; i++ {
		dblk, err := db.FetchDBlockByHeight(i)
		if err != nil {
			return
		}
		if dblk == nil {
			return
		}
		for _, v := range dblk.GetDBEntries() {
			if v.GetChainID().IsMinuteMarker() == true {
				continue
			}
			eBlock, err := db.FetchEBlock(v.GetKeyMR())
			if err != nil {
				return
			}
			resp.EBlocks = append(resp.EBlocks, eBlock)
			for _, v := range eBlock.GetBody().GetEBEntries() {
				entry, err := db.FetchEntry(v)
				if err != nil {
					return
				}
				resp.Entries = append(resp.Entries, entry)
			}
		}
	}

	resp.SetOrigin(m.GetOrigin())
	resp.SetNetworkOrigin(m.GetNetworkOrigin())
	resp.SendOut(state, resp)
	state.IncDBStateAnswerCnt()

	return
}
開發者ID:FactomProject,項目名稱:factomd,代碼行數:48,代碼來源:missingEntryBlocks.go


注:本文中的github.com/FactomProject/factomd/common/interfaces.IState.IncDBStateAnswerCnt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。