예제 #1
0
 /**
  * BetterNode constructor.
  * @param ConfigProviderInterface $config
  * @param ParamsInterface $params
  * @param DbInterface $db
  */
 public function __construct(ConfigProviderInterface $config, ParamsInterface $params, DbInterface $db)
 {
     $math = Bitcoin::getMath();
     $adapter = Bitcoin::getEcAdapter($math);
     $this->chains = new ChainContainer($math, $params);
     $consensus = new Consensus($math, $params);
     $pow = new ProofOfWork($math, $params);
     $this->headers = new Index\Headers($db, $adapter, $this->chains, $consensus, $pow);
     $this->blocks = new Index\Blocks($db, $config, $adapter, $this->chains, $consensus);
     $this->transactions = new Index\Transactions($db);
     $genesis = $params->getGenesisBlock();
     $this->headers->init($genesis->getHeader());
     $this->blocks->init($genesis);
     $this->db = $db;
     $segments = $this->db->fetchChainSegments();
     foreach ($segments as $segment) {
         $this->chains->addSegment($segment);
     }
     $this->chains->initialize($this->db);
 }
예제 #2
0
 /**
  * @return Chain\ChainSegment[]
  */
 public function fetchChainSegments()
 {
     echo __FUNCTION__ . PHP_EOL;
     return $this->db->fetchChainSegments();
 }