Get the last block processed
    Return the integer on success
    Return None on error
491519
def get_last_block(working_dir):
    

    # make this usable even if we haven't explicitly configured virtualchain 
    impl = sys.modules[__name__]
    return BlockstackDB.get_lastblock(impl, working_dir)
3065
async function getCurrentServerTimeAndBlock() {
    await retrieveDynGlobProps();
    if(props.time) { 
        lastCommitedBlock = props.last_irreversible_block_num;
        trace("lastCommitedBlock = " + lastCommitedBlock + ", headBlock = " + props.head_block_number);
        return {
            time : Date.parse(props.time), 
            block : props.head_block_number,
            commited_block :  props.last_irreversible_block_num
        };
    }
    throw "Current time could not be retrieved";
}
1126427
def get_current_block_hash(self, is_full: bool = False) -> str:
        
        payload = self.generate_json_rpc_payload(RpcMethod.GET_CURRENT_BLOCK_HASH)
        response = self.__post(self.__url, payload)
        if is_full:
            return response
        return response['result']
541630
def last(options = nil, &block)
      options = options ? Hash[options] : {}
      options[:what] = :last
      options[:count] ||= 1
      find(options, &block)
    end
82543
def get():
    """"""

    LOG.debug('GET Processing Block list')
    _url = get_root_url()

    # Get list of Processing block Ids
    block_ids = sorted(DB.get_processing_block_ids())
    LOG.debug('Processing Block IDs: %s', block_ids)

    # Construct response object
    response = dict(num_processing_blocks=len(block_ids),
                    processing_blocks=list())

    # Loop over blocks and add block summary to response.
    for block in DB.get_block_details(block_ids):
        block_id = block['id']
        LOG.debug('Creating PB summary for %s', block_id)
        block['links'] = dict(
            detail='{}/processing-block/{}'.format(_url, block_id),
            scheduling_block='{}/scheduling-block/{}'
            .format(_url, block_id.split(':')[0])
        )
        response['processing_blocks'].append(block)
    response['links'] = {
        'self': '{}'.format(request.url),
        'home': '{}'.format(_url)
    }
    return response, HTTPStatus.OK
368846
def get_last(self):
        
        query = self.table().where('batch', self.get_last_batch_number())

        return query.order_by('migration', 'desc').get()
768971
def get_epoch_number( block_height ):
    
    global EPOCHS

    if block_height <= EPOCHS[0]['end_block']:
        return 0

    for i in xrange(1, len(EPOCHS)):
        if EPOCHS[i-1]['end_block'] < block_height and (block_height <= EPOCHS[i]['end_block'] or EPOCHS[i]['end_block'] == EPOCH_NOW):
            return i

    # should never happen 
    log.error("FATAL: No epoch for %s" % block_height)
    os.abort()
706466
def last(self):
        """"""
        with self.lock:
            try:
                return self.data[-1][0]
            except IndexError as ex:
                ex.args = ('DEPQ is empty',)
                raise
32236
def updateIfNeeded(self):
        """"""
        headBlock = self.db.reader._get_head_block()
        if headBlock is not None:
            # avoid restarting search if head block is same & we already initialized
            # this is required for fastSync handling
            if self.lastBlock is not None:
                self.lastBlock = max(self.lastBlock, headBlock.number)
            else:
                self.lastBlock = headBlock.number
        lastProcessed = self.db.reader._get_last_indexed_number()
        if lastProcessed is not None:
            self.lastProcessedBlock = utils.big_endian_to_int(lastProcessed)

        # in fast sync head block is at 0 (e.g. in fastSync), we can't use it to determine length
        if self.lastBlock is not None and self.lastBlock == 0:
            self.lastBlock = 2e9

        if self.lastBlock is None or (
            self.lastProcessedBlock is not None
            and self.lastBlock <= self.lastProcessedBlock
        ):
            return

        blockNum = 0
        if self.lastProcessedBlock is not None:
            blockNum = self.lastProcessedBlock + 1
            print(
                "Updating hash-to-address index from block "
                + str(self.lastProcessedBlock)
            )
        else:
            print("Starting hash-to-address index")

        count = 0
        processed = 0

        while blockNum <= self.lastBlock:
            # leveldb cannot be accessed on multiple processes (not even readonly)
            # multithread version performs significantly worse than serial
            try:
                results = self._process(blockNum)
            except:
                break

            # store new mappings
            self.db.writer._start_writing()
            count += len(results)
            for addr in results:
                self.db.writer._store_account_address(addr)

            self.db.writer._commit_batch()

            processed += BATCH_SIZE
            blockNum = min(blockNum + BATCH_SIZE, self.lastBlock + 1)

            cost_time = time.time() - ethereum.start_time
            print(
                "%d blocks processed (in %d seconds), %d unique addresses found, next block: %d"
                % (processed, cost_time, count, min(self.lastBlock, blockNum))
            )

            self.lastProcessedBlock = blockNum - 1
            self.db.writer._set_last_indexed_number(self.lastProcessedBlock)

        print("Finished indexing")
        self.lastBlock = self.lastProcessedBlock
1268096
def result(self):
        
        if self.exception():
            raise self.exception()
        # Otherwise return a context manager that cleans up after the block.

        @contextlib.contextmanager
        def f():
            try:
                yield self._wrapped.result()
            finally:
                self._exit_callback()
        return f()
203442
def next(self):
        '''
        
        '''
        if self.__buffered is None:
            # Use floor division to force multiplier to an integer
            multiplier = self.__max_in_mem // self.__chunk_size
            self.__buffered = ""
        else:
            multiplier = 1
            self.__buffered = self.__buffered[self.__chunk_size:]

        data = self.__file.read(self.__chunk_size * multiplier)
        # Data is a byte object in Python 3
        # Decode it in order to append to self.__buffered str later
        # Use the salt util in case it's already a string (Windows)
        data = salt.utils.stringutils.to_str(data)

        if not data:
            self.__file.close()
            raise StopIteration

        self.__buffered += data
        return self.__buffered
928015
def next_block(self):
        

        assert self.pos <= self.input_len
        if self.pos == self.input_len:
            return None

        # Overshoot
        i = self.START_OVERSHOOT

        while True:
            try_size = int(self.bs * i)
            size = self.check_request_size(try_size)
            c, d = self.compress_next_chunk(size)

            if size != try_size:
                break

            if len(d) < self.bs:
                i += self.OVERSHOOT_INCREASE
            else:
                break

        # Reduce by one byte until we hit the target
        while True:

            if len(d) <= self.bs:

                self.c = c
                # self.c = self.factory()
                crc32 = zlib.crc32(self.get_input(size), 0xffffffff) & 0xffffffff
                self.pos += size
                self.compressed_bytes += len(d)
                return crc32, size, d

            size -= 1

            if size == 0:
                return None

            c, d = self.compress_next_chunk(size)
1146281
def estimate_blocktime(self, oldest: int = 256) -> float:
        
        last_block_number = self.block_number()
        # around genesis block there is nothing to estimate
        if last_block_number < 1:
            return 15
        # if there are less than `oldest` blocks available, start at block 1
        if last_block_number < oldest:
            interval = (last_block_number - 1) or 1
        else:
            interval = last_block_number - oldest
        assert interval > 0
        last_timestamp = self.get_block_header(last_block_number)['timestamp']
        first_timestamp = self.get_block_header(last_block_number - interval)['timestamp']
        delta = last_timestamp - first_timestamp
        return delta / interval
1324359
def lastChild(self):
        '''
            
        '''
        blocks = object.__getattribute__(self, 'blocks')
        # First block is empty string for indent, but don't hardcode incase that changes
        if blocks[0] == '':
           firstIdx = 1
        else:
           firstIdx = 0

        if len(blocks) <= firstIdx:
            return None

        return blocks[-1]
1145949
def last(self, db=_DefaultDB):
        '''
        
        '''
        self._acqXactForReading()
        try:
            with self.xact.cursor(db=db.db) as curs:
                if not curs.last():
                    return None
                return curs.key(), curs.value()
        finally:
            self._relXactForReading()
152495
def get(self, block=True, timeout=None):
        
        value = self._queue.get(block, timeout)
        if self._queue.empty():
            self.clear()
        return value
1036350
def _get_last_state(self, state_file):
        """"""
        state = None
        fp = open(state_file)
        try:
            state = int(fp.read())
            print("Found previous state: %d" % (state,))
        finally:
            fp.close()
        return state