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 }
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 }