Giter Club home page Giter Club logo

blockstack-explorer's Introduction

Blockstack Explorer

Setup

In order to run this app, you first need to install redis. If you're on a Mac, you can install and run redis by running brew install redis.

Setting up redis

After installing redis, run

yarn redis

To start a default instance of redis.

First Time Use

Pre-caching data

We use redis to pre-cache some data that normally would take quite a few API requests. To pre-cache all data, run:

yarn setup

You only need to run this script once. To get fresh data, you can run the script again. In production, this script will run on a scheduled basis.

Development

The packages will have been installed after running yarn setup.

To run the dev server, run yarn dev.

Next.js Docs

This project was bootstrapped with Create Next App.

Find the most recent version of this guide at here. And check out Next.js repo for the most up-to-date info.

Table of Contents

Questions? Feedback?

Check out Next.js FAQ & docs or let us know your feedback.

Folder Structure

After creating an app, it should look something like:

my-app/
  README.md
  package.json
  next.config.js
  components/
    head.js
    nav.js
  pages/
    index.js
  static/
    favicon.ico

Routing in Next.js is based on the file system, so ./pages/index.js maps to the / route and ./pages/about.js would map to /about.

The ./static directory maps to /static in the next server, so you can put all your other static resources like images or compiled CSS in there.

Out of the box, we get:

  • Automatic transpilation and bundling (with webpack and babel)
  • Hot code reloading
  • Server rendering and indexing of ./pages
  • Static file serving. ./static/ is mapped to /static/

Read more about Next's Routing

Available Scripts

In the project directory, you can run:

npm run dev

Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.

The page will reload if you make edits.
You will also see any errors in the console.

npm run build

Builds the app for production to the .next folder.
It correctly bundles React in production mode and optimizes the build for the best performance.

npm run start

Starts the application in production mode. The application should be compiled with `next build` first.

See the section in Next docs about deployment for more information.

Using CSS

styled-jsx is bundled with next to provide support for isolated scoped CSS. The aim is to support "shadow CSS" resembling of Web Components, which unfortunately do not support server-rendering and are JS-only.

export default () => (
  <div>
    Hello world
    <p>scoped!</p>
    <style jsx>{`
      p {
        color: blue;
      }
      div {
        background: red;
      }
      @media (max-width: 600px) {
        div {
          background: blue;
        }
      }
    `}</style>
  </div>
);

Read more about Next's CSS features.

Adding Components

We recommend keeping React components in ./components and they should look like:

./components/simple.js

const Simple = () => <div>Simple Component</div>;

export default Simple; // don't forget to export default!

./components/complex.js

import { Component } from 'react';

class Complex extends Component {
  state = {
    text: 'World',
  };

  render() {
    const { text } = this.state;
    return <div>Hello {text}</div>;
  }
}

export default Complex; // don't forget to export default!

Fetching Data

You can fetch data in pages components using getInitialProps like this:

./pages/stars.js

const Page = (props) => <div>Next stars: {props.stars}</div>;

Page.getInitialProps = async ({ req }) => {
  const res = await fetch('https://api.github.com/repos/zeit/next.js');
  const json = await res.json();
  const stars = json.stargazers_count;
  return { stars };
};

export default Page;

For the initial page load, getInitialProps will execute on the server only. getInitialProps will only be executed on the client when navigating to a different route via the Link component or using the routing APIs.

Note: getInitialProps can not be used in children components. Only in pages.

Read more about fetching data and the component lifecycle

Custom Server

Want to start a new app with a custom server? Run create-next-app --example customer-server custom-app

Typically you start your next server with next start. It's possible, however, to start a server 100% programmatically in order to customize routes, use route patterns, etc

This example makes /a resolve to ./pages/b, and /b resolve to ./pages/a:

const { createServer } = require('http');
const { parse } = require('url');
const next = require('next');

const dev = process.env.NODE_ENV !== 'production';
const app = next({ dev });
const handle = app.getRequestHandler();

app.prepare().then(() => {
  createServer((req, res) => {
    // Be sure to pass `true` as the second argument to `url.parse`.
    // This tells it to parse the query portion of the URL.
    const parsedUrl = parse(req.url, true);
    const { pathname, query } = parsedUrl;

    if (pathname === '/a') {
      app.render(req, res, '/b', query);
    } else if (pathname === '/b') {
      app.render(req, res, '/a', query);
    } else {
      handle(req, res, parsedUrl);
    }
  }).listen(3000, (err) => {
    if (err) throw err;
    console.log('> Ready on http://localhost:3000');
  });
});

Then, change your start script to NODE_ENV=production node server.js.

Read more about custom server and routing

Syntax Highlighting

To configure the syntax highlighting in your favorite text editor, head to the relevant Babel documentation page and follow the instructions. Some of the most popular editors are covered.

Deploy to Now

now offers a zero-configuration single-command deployment.

  1. Install the now command-line tool either via the recommended desktop tool or via node with npm install -g now.

  2. Run now from your project directory. You will see a now.sh URL in your output like this:

    > Ready! https://your-project-dirname-tpspyhtdtk.now.sh (copied to clipboard)
    

    Paste that URL into your browser when the build is complete, and you will see your deployed app.

You can find more details about now here.

Something Missing?

If you have ideas for how we could improve this readme or the project in general, let us know or contribute some!

blockstack-explorer's People

Contributors

andrewfhart avatar aulneau avatar bechi avatar braydonf avatar cmgustavo avatar codegenieur avatar dabura667 avatar defipanda avatar dependabot[bot] avatar eveiv avatar hstove avatar ionux avatar jcnelson avatar kantai avatar kleetus avatar koirikivi avatar larrysalibra avatar maraoz avatar martindale avatar matiu avatar pnagurny avatar sandakersmann avatar shea256 avatar slavik0329 avatar timstackblock avatar visvirial avatar wozz avatar yemel avatar yknl avatar zone117x avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

blockstack-explorer's Issues

Make name operation counts update as new blocks appear

Insight-api pushes new blocks as they are mined - we don't currently request name operations in the new blocks as this happens.

screen shot 2016-11-04 at 1 14 54 am

One complication is that name operations in a block aren't available until blockstack core has had a chance to process the block, which is typically after the block is pushed to the UI by insight-api.

Monitor & auto-restart bitcore node

Bitcore node starts it's own patched bitcoind process on launch. Bitcore itself periodically dies (#25) leaving bitcoind running. To restart bitcore, one needs to stop bitcoind and restart bitcore. Stopping bitcoind entails stopping blockstack-server which depends bitcoind.

We'd like to monitor and auto-restart bitcore node. To do this, we need to change the bitcore node's configuration to use an external bitcoind instance.

Story: Explorer update

Users should be able to use an upgrade version of the explorer that:

  • uses the current core version
  • properly displays verifications using the new verification system
  • has updated endpoints (need to move these over into an issue from the paper document)

Action items (in order of declining priority):

  • Use Core API: #45
  • Address page should list profile cards for owned names: #44
  • Move to id.blockstack.org #49
  • New endpoints #48
  • Use search from core.blockstack.org: #43
  • Show potentially valid blockstack transactions in current blocks #46

Improve search field

Add search by:
*namespace โ˜‘๏ธ
~~*name without the .id~~ (shouldn't treat .id` as privileged)
*partial name

Stream possible blockstack transactions

As new transaction enter the mempool that have OP_RETURN data in blockstack transaction format, display them on the explorer.

The explorer is currently subscribing to bitcore-node's mempool streaming transaction event which only contains the following information:

{"txid":"e9673b332ef2fabd850f1d5d6349c92447a8096ad9448cd7f87c8add47d6840e","valueOut":25.96761385,"vout":[{"1BYLKJeMkvDEX82LgL2YzzDq4sj6YyP4Jj":60000},{"39WFvAEK1sLiSgweD3KmLw2BL89nGStqwB":2596701385}],"isRBF":false}    

There's also an event bitcoind/rawtransaction or another event that we might be able subscribe to that would provide the necessary information.

Move to id.blockstack.org

  1. Ensure production server will work on id.blockstack.org (@larrysalibra)
  2. Move current explorer.blockstack.org records to id.blockstack.org (@shea256)
  3. Add a permanent redirect to explorer.blockstack.org that so that old links don't break (@shea256)

Loading block name operations fails for some blocks

In certain blocks that have many name operations, it takes on the order of minutes for blockstack-cli get_nameops_at to generate a result causing our reverse proxy and/or the user's browser to timeout before the request can return.

This should be fixed once we can migrate to blockstack core http api #7.

In the meantime, I have set up https://explorer.blockstack.org to cache get_nameops_at queries in a local varnish instance. This will speed up requests after the first request but unfortunately won't help with the largest (in terms of number of name operations) of blocks.

Pricing information tools for names & namespaces

This could be the same widget that's displayed on the namespace page in #18 displayed on its own page or on the index page.

Indicate if the name is available or already registered. If it's available, display registration instructions/options similar to those in #19.

Improve display of zonefile

Format and syntax highlight the zonefile.
It could also be interesting to parse and interpret the zonefile for visitors.

screen shot 2016-11-04 at 1 28 58 am

Update translations

We need to update existing (German, Spanish, Japanese) translations. If we can't maintain them, we should remove them.

Add explanatory tips/links

Add tooltips or links to documentation explaining the meaning of various terms such as those in blockchain history records.

screen shot 2016-11-04 at 1 58 33 am

Unregistered name page

When a user searches for a name that doesn't exist, we could display a page with instructions on how to register the name and how much it would cost.

Expiry block doesn't display

Expiry block doesn't show for names. The reason is that we switched from get_name_blockchain_record to using get_name_blockchain_history which has the expanded history but is missing the expiry_block key.

Reduce verbosity of logs

Earlier today, the explorer server ran out of disk space on its root partition. The process manager (pm2) logs command output which is good in case something dies. I set up a log rotator for pm2 which should minimize the problem is the future. I also moved the pm2 logs from the small 29gb root partition to the 1 TB /data partition.

It would also be great to reduce the amount of debug information that gets printed out by blockstack-server (we're running it with --foreground so that pm2)

@jcnelson, is there a command switch on the server to reduce verbosity?

Use search from core.blockstack.org

The search on explorer.blockstack is not showing some profiles (we've seen a few support tickets).

I'd suggest using the search endpoint from https://core.blockstack.org instead. That's where the most recent version of search will live for now and we index pretty frequently there.

Tagging @kantai who updated search there recently.

Bitcore mysteriously dying

The couple days or so, Bitcore Node has started mysteriously dying. (bitcoind, blockstack-server and the explorer API keep running)

@shea256 mentioned having a similar problem with Bitcore Node stopping and suggested we'd need to add a watchdog.

Not sure why this problem crept up after having disappeared for so many weeks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.