Esempio n. 1
0
          /**
           *  Received in response to get_headers message, we should certify that we requested this.
           */
          void handle_headers( const connection_ptr& con,  chan_data& cdat, const headers_message& msg )
          { try {
              FC_ASSERT( !!cdat.requested_headers );
              cdat.requested_headers.reset();
              
              // TODO: validate that all ids reported have the min proof of work for a name.

              ilog( "received ${x} block headers", ("msg",msg.headers.size() ) );
              _fork_db.cache_header( msg.first );
              _new_block_info = true;
              name_id_type prev_id = msg.first.id();
              for( auto itr = msg.headers.begin(); itr != msg.headers.end(); ++itr )
              {
                 name_header next_head( *itr, prev_id );
                 ilog( "${id} = ${next_head}", ("id",next_head.id())("next_head",next_head) );
                 _fork_db.cache_header( next_head );
                 prev_id = next_head.id();

                 if( prev_id > max_name_hash() )
                 {
                    // then we should disconnect.... 
                    wlog( "node produced name header with insufficient minimum work" );
                    con->close();
                    return;
                 }

                 cdat.available_blocks.insert(prev_id);
              }

              if( prev_id != msg.head_block_id )
              {
                  cdat.requested_headers = fc::time_point::now();
                  get_headers_message  request;
                  request.locator_hashes.push_back( prev_id );
                  con->send( network::message( request, _chan_id ) );
              }
              
          } FC_RETHROW_EXCEPTIONS( warn, "", ("msg",msg) ) } 
Esempio n. 2
0
 uint64_t min_name_difficulty() 
 {
     return difficulty(max_name_hash()); 
 }