Used to break up requests to ``eth_getLogs``

    The getLog request is partitioned into multiple calls of the max number of blocks
    ``max_blocks``.
495255
def get_logs_multipart(
        w3,
        startBlock,
        stopBlock,
        address,
        topics,
        max_blocks):
    
    _block_ranges = block_ranges(startBlock, stopBlock, max_blocks)
    for from_block, to_block in _block_ranges:
        params = {
            'fromBlock': from_block,
            'toBlock': to_block,
            'address': address,
            'topics': topics
        }
        yield w3.eth.getLogs(
            drop_items_with_none_value(params))
430968
def idle_send_acks_and_nacks(self):
        ''''''
        max_blocks_to_send = 10
        blocks_sent = 0
        i=0
        now = time.time()
        while i < len(self.blocks_to_ack_and_nack) and blocks_sent < max_blocks_to_send:
#            print("ACKLIST: %s" % ([x[1] for x in self.blocks_to_ack_and_nack],))
            stuff = self.blocks_to_ack_and_nack[i]

            [master, block, status, first_sent, last_sent] = stuff
            if status == 1:
#                print("DFLogger: ACKing block (%d)" % (block,))
                self.master.mav.remote_log_block_status_send(block,status)
                blocks_sent += 1
                del self.acking_blocks[block]
                del self.blocks_to_ack_and_nack[i]
                continue

            if block not in self.missing_blocks:
                # we've received this block now
                del self.blocks_to_ack_and_nack[i]
                continue

            # give up on packet if we have seen one with a much higher
            # number:
            if self.block_cnt - block > 200 or \
               now - first_sent > 60:
                print("DFLogger: Abandoning block (%d)" % (block,))
                del self.blocks_to_ack_and_nack[i]
                del self.missing_blocks[block]
                self.abandoned += 1
                continue

            i += 1
            # only send each nack every-so-often:
            if last_sent is not None:
                if now - last_sent < 0.1:
                    continue

            print("DFLogger: NACKing block (%d)" % (block,))
            self.master.mav.remote_log_block_status_send(block,status)
            blocks_sent += 1
            stuff[4] = now
1125628
def fetch_block(block_size=nil)
      block_size ||= @block_size ||= @options.fetch(:block_size) { 1000 }
      @result = @connection.execute("fetch #{block_size} from cursor_#{@cursor}")

      if @iterate == :each_array
        @block = @result.each_row.collect {|row| row }
      else
        @block = @result.collect {|row| row }
      end
    end
791519
def _fetchBlock(self):
        
        # make sure that another block request is not standing
        if self._blockRequestInProgress :
           # need to wait here before returning... (TODO)
           return

        # make sure another block request has not completed meanwhile
        if self._standbyBlock is not None: 
           return

        self._blockRequestInProgress = True
        fetchReq = TFetchResultsReq(operationHandle=self.operationHandle,
                                    orientation=TFetchOrientation.FETCH_NEXT,
                                    maxRows=self.arraysize)
        self._standbyBlock = self._fetch([],fetchReq)
        self._blockRequestInProgress = False
        return
1107793
def poll_blockchain_events(self, block_number: typing.BlockNumber):
        

        for event_listener in self.event_listeners:
            assert isinstance(event_listener.filter, StatelessFilter)

            for log_event in event_listener.filter.get_new_entries(block_number):
                yield decode_event_to_internal(event_listener.abi, log_event)
337428
def get_blocks(self, chrom, start, end):
    
    if chrom not in self.block_trees:
      return []
    return self.block_trees[chrom].intersectingInterval(start, end)
201932
def getUncleByBlock(self, block_identifier, uncle_index):
        
        method = select_method_for_block_identifier(
            block_identifier,
            if_predefined='eth_getUncleByBlockNumberAndIndex',
            if_hash='eth_getUncleByBlockHashAndIndex',
            if_number='eth_getUncleByBlockNumberAndIndex',
        )
        result = self.web3.manager.request_blocking(
            method,
            [block_identifier, uncle_index],
        )
        if result is None:
            raise BlockNotFound(
                f"Uncle at index: {uncle_index} of block with id: {block_identifier} not found."
            )
        return result
870755
function fetchLogs(root, msg, callback) {
    const number = msg.number;
    const logfile = msg.logfile;
    const serverId = msg.serverId;
    const filePath = path.join(root, getLogFileName(logfile, serverId));

    const endLogs = [];
    exec(`tail -n ${number} ${filePath}`, (error, output) => {
        const endOut = [];
        output = output.replace(/^\s+|\s+$/g, '').split(/\s+/);

        for (let i = 5; i < output.length; i += 6) {
            endOut.push(output[i]);
        }

        const endLength = endOut.length;
        for (let j = 0; j < endLength; j++) {
            const map = {};
            let json;
            try {
                json = JSON.parse(endOut[j]);
            } catch (e) {
                logger.error(`the log cannot parsed to json, ${e}`);
                continue;   // eslint-disable-line
            }
            map.time = json.time;
            map.route = json.route || json.service;
            map.serverId = serverId;
            map.timeUsed = json.timeUsed;
            map.params = endOut[j];
            endLogs.push(map);
        }

        callback({ logfile: logfile, dataArray: endLogs });
    });
}
965213
def get_logs(self, stdout=True, stderr=True, timestamps=False, tail='all',
                 since=None):
        
        return self.inner().logs(
            stdout=stdout, stderr=stderr, timestamps=timestamps, tail=tail,
            since=since)
1306330
private long search_ml(int request_size)
    throws IOException
    {
        Block best_candidate = null;
        Block best_candidate_pred = null;
        Block block = ql_heads[last_ql_index].first_block;
        long block_addr;
        boolean found = false;
        Block prev_block = null;
        int ql_index;
        int ql_size;
        int rem;
        int rem2;

        large_requests++;
        while (block != null) {
            ml_blocks_searched++;
            if (block.size >= request_size) {
                rem = block.size - request_size;
                if (rem <= acceptable_waste) {
                    // allocate the block without splitting
                    if (prev_block != null) {
                        prev_block.next = block.next;
                    } else {
                        ql_heads[last_ql_index].first_block = block.next;
                    }
                    ql_heads[last_ql_index].length--;
                    if (ql_heads[last_ql_index].length == 0) {
                        nonempty_lists--;
                    }

                    allocated_blocks++;
                    free_blocks--;
                    ml_hits++;
                    allocated_words += block.size;
                    free_words -= block.size;

                    seek_and_count(block.address);
                    writeInt(- block.size);

                    return(block.address + HDR_SIZE);
                } else {
                    if (best_candidate == null) {
                        best_candidate = block;
                        best_candidate_pred = prev_block;
                    } else {
                        if (best_candidate.size >= block.size) {
                            best_candidate = block;
                            best_candidate_pred = prev_block;
                        }
                    }
                }
            }
            prev_block = block;
            block = block.next;
        }
        if (best_candidate == null) {
            // have to allocate from tail
            return allocate_from_tail(request_size);
        } else {
            // we have to split a block
            rem = best_candidate.size - request_size;
            block_addr = best_candidate.address;
            if (rem <= last_quick_size_block) {
                rem2 = rem % grain_size;
                rem -= rem2;
                ql_index = calculate_list_index_for_dealloc(rem);
                request_size += rem2;
                if (best_candidate_pred != null) {
                    best_candidate_pred.next = best_candidate.next;
                } else {
                    ql_heads[last_ql_index].first_block = best_candidate.next;
                }
                add_block_to_freelist(best_candidate, ql_index);
            }
            best_candidate.size = rem;
            best_candidate.address += request_size;
            return split_block(block_addr, request_size, rem);
        }

    }
332959
private long allocate_from_ql(int request_size)
    throws IOException
    {
        Block block1;
        int block_size;
        int list_index;

        small_requests++;
        list_index = calculate_list_index_for_alloc(request_size);
        if (ql_heads[list_index].length > 0 ) {
            // quick list is nonempty
            block1 = ql_heads[list_index].first_block;
            ql_heads[list_index].length--;
            if (ql_heads[list_index].length == 0) {
                nonempty_lists--;
            }
            ql_heads[list_index].first_block = block1.next;

            allocated_blocks++;
            free_blocks--;
            ql_hits++;
            allocated_words += block1.size;
            free_words -= block1.size;

            // do the following as late as possible
            seek_and_count(block1.address);
            writeInt(- block1.size);

            return(block1.address + HDR_SIZE);
        } else {
            // allocate from tail
            block_size = calculate_block_size(list_index);
            return allocate_from_tail(block_size);

        }
    }
404909
def get_block_count(self, is_full: bool = False) -> int or dict:
        
        payload = self.generate_json_rpc_payload(RpcMethod.GET_BLOCK_COUNT)
        response = self.__post(self.__url, payload)
        if is_full:
            return response
        return response['result']
1215427
def locked_blocks_iterator(blockfile, start_info=(0, 0), cached_headers=50, batch_size=50):
    
    f = blockfile
    current_state = []

    def change_state(bc, ops):
        for op, bh, work in ops:
            if op == 'add':
                current_state.append(bh)
                pass
            else:
                current_state.pop()
    bc = BlockChain()
    bc.add_change_callback(change_state)
    bhs = []
    index = 0
    info_offset = start_info
    while 1:
        v = blockfile.next_offset(info_offset)
        if v is None:
            break
        block_offset, info_offset = v
        f.jump_to(block_offset)
        bh = Block.parse_as_header(f)
        bh.info = block_offset

        bhs.append(bh)
        if len(bhs) > batch_size:
            bc.add_headers(bhs)
            bhs = []
            if len(current_state) > cached_headers:
                for bh in current_state[:cached_headers]:
                    bh.index = index
                    yield bh
                    index += 1
                    bc.lock_to_index(index)
                current_state = current_state[cached_headers:]
562744
public Block getBlock(String sqlquery, Collection queryParams, int startIndex, int count) {
		return blockStrategy.getBlock(sqlquery, queryParams, startIndex, count);
	}
1116239
def get_ancestors(self, limit: int, header: BlockHeader) -> Tuple[BaseBlock, ...]:
        
        ancestor_count = min(header.block_number, limit)

        # We construct a temporary block object
        vm_class = self.get_vm_class_for_block_number(header.block_number)
        block_class = vm_class.get_block_class()
        block = block_class(header=header, uncles=[])

        ancestor_generator = iterate(compose(
            self.get_block_by_hash,
            operator.attrgetter('parent_hash'),
            operator.attrgetter('header'),
        ), block)
        # we peel off the first element from the iterator which will be the
        # temporary block object we constructed.
        next(ancestor_generator)

        return tuple(take(ancestor_count, ancestor_generator))
1243198
def log_iter(self, maxentries=None, template=None, **kwargs):
        
        # op = self.sh((
        #   "hg log %s --template"
        #   % (maxentries and ('-l%d' % maxentries) or '')),
        #   ignore_error=True
        # )
        template = str(template or self.template)
        op = self.log(n=maxentries, template=template, **kwargs)
        if not op:
            return
        print(op)
        for l in itersplit(op, self.lsep):
            l = l.strip()
            if not l:
                continue
            try:
                yield self._parselog(l,)
            except Exception:
                log.error("%s %r" % (str(self), l))
                raise
        return
919852
def fetchall(self):
        
        result = r = self.fetchmany(size=self.FETCHALL_BLOCKSIZE)
        while len(r) == self.FETCHALL_BLOCKSIZE or not self._received_last_resultset_part:
            r = self.fetchmany(size=self.FETCHALL_BLOCKSIZE)
            result.extend(r)
        return result