Method
FetchBlockByCount
(req *types.FetchBlockByCountReq, resp *types.FetchBlockResp)
Source from the content-addressed store, hash-verified
| 154 | } |
| 155 | |
| 156 | func (s *stubBPService) FetchBlockByCount(req *types.FetchBlockByCountReq, resp *types.FetchBlockResp) (err error) { |
| 157 | count := atomic.LoadUint32(&s.count) |
| 158 | if req.Count > count { |
| 159 | return ErrNotExists |
| 160 | } |
| 161 | if bi, ok := s.blockMap[req.Count%2]; ok { |
| 162 | resp.Count = bi.c |
| 163 | resp.Height = bi.h |
| 164 | resp.Block = bi.block |
| 165 | } |
| 166 | return |
| 167 | } |
| 168 | |
| 169 | func (s *stubBPService) Init() { |
| 170 | s.blockMap = make(map[uint32]*blockInfo) |
Tested by
no test coverage detected