bitcoin core – How do I get old blocks while running a pruned node?

Hello I’m trying to build a NodeJS app that fetches Bitcoin blocks, potentially old ones, and I’m running into issues. I’ve downloaded Bitcoin Core but I don’t have enough space to run a full node and so I opted to run a pruned one. However, when I go to query an old block it tells me that the block isn’t available in pruned mode. So my question is, why doesn’t Bitcoin Core query the block on the fly from another node if it doesn’t find it on disk? It clearly has the ability to do this, else how would it sync the blocks in the first place? If this is not possible with Bitcoin Core, could I build my own JS app that mimics the network calls used in the IBD to get blocks on demand, instead of saving them to disk? Also, I can’t use a 3rd party block explorer API because they don’t have all the features I want and they are less reliable.

8 – How to re-order node fields in views generated from ID?

I have a content type with fields: title, hours_worked, work_done.

I’ve created a view that gets the node ID from URL and outputs the fields of the target node: hours_worked and work_done. How do I introduce the ability to re-order which of the fields comes first in a drag and drop manner?

It’s similar to the functionality you get in Draggableviews/sortableiews/weight modules which are for re-ordering list of nodes but this requirement is for fields of specific node.

8 – Re-order node fields in views generated from ID

Say my content type has fields: title, hours_worked, work_done. I want to be able to click a button that presents a views of the target node’s some of the fileds: hours_worked and work_done fields with the ability to re-order which comes first in a drag and drop manner. Drupal 7 has this in the field_weight module but it has no D8 version.

It’s similar to the functionality you get in Draggableviews/sortableiews/weight modules which are for re-ordering list of nodes but this requirement is for fields of specific node.

7 – How to pre-populate a text field when creating a new node?

I am using Drupal 7. I have a Content Type called Request. I have two fields “Manager Name” (type Text) and “Manager Email Address” (type Email). When the user creates a new node of type Request, I want to pre-fill these fields with “Hello World” and “”. Here is what I have tried so far (This is all in mymodule_form_node_form_alter):

$form('field_manager_name')('und')('#default_value') = "Hello World";
$form('field_manager_name')('und')('#suffix') = "Enter in the name of your immediate supervisor.";
$form('field_manager_email_address')('und')('#default_value') = "";
$form('field_manager_email_address')('und')('#suffix') = "Enter in the email address of your immediate supervisor.";

The two suffixes are working. When I create a new node of type Request, the suffix text appears under the field name, as expected. But the “default_value” fields are not working. What am I doing wrong?

javascript – Is there a less complicated alternative to handling this simple mySQL query in Node?

To Put My Question In Better Context…

I am about done writing my first real-world Node application, which would be classified as a REST API. For myself, it was a bit challenging to wrap my head around Node’s Async event processing. I still don’t think I fully grasp it, as you will see by the specifics of this post. That being said…

Am I Making This Overly Complicated?

I found some code snippets online that helped me get my API working. Below is one function that deals with finding a client. I guess you would call the file this is in, a Controller, for those of you familiar with MVC. But this being Node, and NOT MVC, my question is this:

GET http://localhost/clients/3 -> brings me to this code…

// Find a single client with a Id
exports.findOne = (req, res) => {
  Client.findById(req.params.clientId, (err, data) => {
    if (err) {
      if (err.kind === "not_found") {
          message: `Not found Client with id ${req.params.clientId}.`
      } else {
          message: "Error retrieving Client with id " + req.params.clientId
    } else res.send(data);

What is the reason for this call to have a callback itself???

Client.findById(req.params.clientId, (err, data) => {

which in turn, looks like this:

Client.findById = (clientId, result) => {
  sql.query(`SELECT * FROM clients WHERE id = ${clientId}`, (err, res) => {
    if (err) {
      console.log("error: ", err);
      result(err, null);

    if (res.length) {
      console.log("found client: ", res(0));
      result(null, res(0));

    // not found client with the id
    result({ kind: "not_found" }, null);

This seems like a lot of work for a simple query function. Coming from a PHP background, this could be done in very few lines of code there.

The whole thing seems complicated. Is all this really necessary for such a simple API that returns a client record of only four columns?

For that matter, do I even need that intermediate function (controller)? What’s the matter with just routing right to the final function (in this case, a function named findById ) ??

I’d sure appreciate some input on this before I get too far ahead. I have another dozen endpoints to code, so if I need to change directions, now would be the time.


javascript – Sessão não persiste (Passport – Mysql – Node – React)

Bom dia, tarde, noite! Ao fazer o login eu sou redirecionado para a rota privada mas quando recarrego a pagina eu sou redirecionado de volta para o login. ao checar o req.isAuthenticated() da função usuarioAutenticado do arquivo routes.js percebi que ela retorna True no momento que faço login e depois se passo pela rota onde tem essa função como middleware é retornado False mesmo logo após fazer o login.

deixei o código onde acredito que possa estar o erro logo abaixo, o projeto esta disponivel no github:


const router = Router();

function usuarioAutenticado() {
    return function(req, res, next) {
        if(req.isAuthenticated()) {
            return next()
        } else {
            return res.status(401).json({
                error: 'User is not authenticated',
                estaAutenticado: false  

router.get('/login', usuarioAutenticado());
router.get('/postar_arte', usuarioAutenticado());

router.get('/postar_arte', (req, res, next) => {
    if(req.isAuthenticated()) {
        return res.status(200).json({
            user: req.user,
            estaAutenticado: true
    } else {
        return res.status(401).json({
            error: 'User is not authenticated',
            estaAutenticado: false
});'/login', passport.authenticate('local'), (req, res, next) => { => {
        if (err) { return next(err) }


const express = require('express');
const http = require('http');
const cors = require('cors');
const router = require('./routes');
const cookieParser = require('cookie-parser');  
const morgan = require('morgan');
const session = require('express-session');
const bodyParser = require('body-parser');
const { errors } = require('celebrate');
const passport = require('passport');
const mysqlStore = require('express-mysql-session')(session);

const app = express();

// Lib de Logs
// app.use(express.json());
// app.use(express.urlencoded({ extended: true }));
app.use(bodyParser.urlencoded({ extended: true }));

    store: new mysqlStore({
        host: process.env.DB_HOST,
        port: process.env.DB_PORT,
        user: process.env.DB_USER,
        password: process.env.DB_PASS,
        database: process.env.DB_NAME,      
        checkExpirationInterval: 900000
    secret: '123', 
    resave: true, 
    saveUninitialized: true 

const server = http.Server(app);
app.use(cors({credentials: true, origin: 'http://localhost:3000'}))

passport.js: (obs: chamei de autorizacao.js)

const bcrypt = require('bcrypt');
const EstrategiaLocal = require('passport-local').Strategy;
const conexao = require('./models/conexao');

module.exports = function(passport){

    passport.serializeUser(function(usuario, done) {
        done(null, usuario.ID);

    passport.deserializeUser(function(id, done) {
        conexao.query('SELECT * FROM Login WHERE ID = ?', (id), (erro, usuario) => {
            done(erro, usuario(0));

    function validarLogin(nome, senha, done) {

        // Consulta para retornar os dados de acordo com o nome enviado no login
        conexao.query('SELECT * FROM Login WHERE nome = ?', (nome), (erro, resultado) => {

            if(erro) {
                return done(erro)

            // se não foi encontrado nenhum usuario
            if(resultado.length == 0) { 
                return done(null, false)

            // comparação da senha enviada no login com o hash que ta no banco de dados
  , resultado(0).senha, (erro, senhaValida) => {

                if(erro) {
                    return done(erro)

                // Senha Inválida
                if(!senhaValida) {
                    console.log('senha invalida')
                    return done(null, false)

                // Senha válida
                console.log('senha correta')
                return done(null, resultado(0))


    passport.use('local', new EstrategiaLocal({ 
            usernameField: 'nome', 
            passwordField: 'senha' 
        //passReqToCallback : true 


bitcoin core – How to get the time when a block is received at a node?

Is there any variable in the bitcoind code that records the timestamp when a block is received for the first time by a particular node?

There happens to be similar existing questions in stackexchange but none of them has been appropriately answered.

unity – A* Pathfinding issues, player node is always off

so I am using Sebastian Lague’s second video on A* pathfinding (, and since he is using a 3d model, and I am using a 2d model, I need to convert some of the values to 2d. It is working fine, but the problem I ran into is that the node that detects the player is always off. enter image description here

Like in here, the cyan node is the node where my player is supposed to be, and the my cursor is where my player actually is. You can see that it is completely off. I am pretty sure this is because some error is produced while I tried to turn 3d into 2d, but I don’t know how. Here is my grid script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Grid : MonoBehaviour
    public Transform player;
    public LayerMask unwalkableMask;
    public Vector2 gridWorldSize;
    public float nodeRadius;
    Node(,) grid;

    float nodeDiameter;
    int gridSizeX, gridSizeY;

    void Start() {
        nodeDiameter = nodeRadius*2;
        gridSizeX = Mathf.RoundToInt(gridWorldSize.x/nodeDiameter);
        gridSizeY = Mathf.RoundToInt(gridWorldSize.y/nodeDiameter);

    void CreateGrid() {
        grid = new Node(gridSizeX,gridSizeY);
        Vector3 worldBottomLeft = transform.position - Vector3.right * gridWorldSize.x/2 - Vector3.up * gridWorldSize.y/2;

        for (int x = 0; x < gridSizeX; x ++) {
            for (int y = 0; y < gridSizeY; y ++) {
                Vector3 worldPoint = worldBottomLeft + Vector3.right * (x * nodeDiameter + nodeRadius) + Vector3.up * (y * nodeDiameter + nodeRadius);
                bool walkable = !(Physics2D.OverlapCircle(worldPoint,nodeRadius,unwalkableMask));
                grid(x,y) = new Node(walkable,worldPoint);

    public Node NodeFromWorldPoint(Vector3 worldPosition) {
        float percentX = (worldPosition.x + gridWorldSize.x/2) / gridWorldSize.x;
        float percentY = (worldPosition.y + gridWorldSize.y/2) / gridWorldSize.y;
        percentX = Mathf.Clamp01(percentX);
        percentY = Mathf.Clamp01(percentY);

        int x = Mathf.RoundToInt((gridSizeX-1) * percentX);
        int y = Mathf.RoundToInt((gridSizeY-1) * percentY);
        return grid(x,y);

    void OnDrawGizmos()
        Gizmos.DrawWireCube(transform.position, new Vector3(gridWorldSize.x, gridWorldSize.y, 1));

        if (grid != null)
            Node playerNode = NodeFromWorldPoint(player.position);

            foreach (Node n in grid) {
                Gizmos.color = (n.walkable)?;
                if (playerNode == n)
                    Gizmos.color = Color.cyan;
                Gizmos.DrawCube(n.worldPosition, * (nodeDiameter-.1f));

And here is my node script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Node
    public bool walkable;
    public Vector3 worldPosition;

    public Node(bool _walkable, Vector3 _worldPos) {
        walkable = _walkable;
        worldPosition = _worldPos;

8 – How to pass field value to referenced node template?

I have content type A. It has field reference to content type B.

I’m rendering referenced node B from content type A twig template like:

{{ content.field_referenced_object }}

And that works well.

I also render some type A filed inside it’s template like:

{{ content.field_some }}

which also works.

Problem is that I need that field_some value to be displayed from referenced object B template instead of object A template, to optimize page markup. How can I pass value from content type A twig template to content type B twig template?

It twig it can be done when including template like:

{% include 'template.html' with {'foo': 'bar'} %}

But is there some analogy for Drupal 8 theming?

full node – Mempool count is too low

I’m running a full node. I wanted to get a list of all mempool txs (using getrawmempool false), and found that it only came back with around 3000, where all the block explorers are currently showing around 12000. I understand that mempools will differ between nodes, but this seems like a very big difference. Can I do anything about this?

Edit: Here is getmempoolinfo:

"size": 1985,
"bytes": 3458091,
"usage": 10785216,
"maxmempool": 300000000,
"mempoolminfee": 0.00001000,
"minrelaytxfee": 0.00001000