Skip to content

Commit d89ecf9

Browse files
committed
lowercase chainstate
1 parent a062e72 commit d89ecf9

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ foreach ($blockchainReader->getChainState()->read() as $utxo) {
4343
$block = $blockchainReader->getBlockByHash('binary hash in little endian');
4444

4545
// get block by height
46-
$block = $blockchainReader->getBlockByHash(12345);
46+
$block = $blockchainReader->getBlockByHeight(12345);
4747

4848
// get best block hash
49-
$hash = $blockchainReader->getChainState()->getBestBlock();
49+
$hash = $blockchainReader->getChainstate()->getBestBlock();
5050
```
5151

5252
See more examples in the examples dir.

examples/read_chainstate.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
include '../vendor/autoload.php';
44

55
$dataDir = getenv('HOME') . '/Library/Application Support/Bitcoin';
6-
$chainStateDir = "$dataDir/chainstate";
6+
$chainstateDir = "$dataDir/chainstate";
77

8-
$reader = new \AndKom\PhpBitcoinBlockchain\ChainStateReader($chainStateDir);
8+
$reader = new \AndKom\PhpBitcoinBlockchain\ChainstateReader($chainstateDir);
99

1010
foreach ($reader->read() as $unspentOutput) {
1111
echo "TX: " . \AndKom\PhpBitcoinBlockchain\Utils::hashToHex($unspentOutput->hash) . "\n";

src/BlockchainReader.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class BlockchainReader
2828
/**
2929
* @var string
3030
*/
31-
protected $chainStateDir;
31+
protected $chainstateDir;
3232

3333
/**
3434
* @var Index
@@ -44,7 +44,7 @@ public function __construct(string $dataDir)
4444
$this->dataDir = $dataDir;
4545
$this->blocksDir = implode(DIRECTORY_SEPARATOR, [$dataDir, 'blocks']);
4646
$this->blockIndexDir = implode(DIRECTORY_SEPARATOR, [$dataDir, 'blocks', 'index']);
47-
$this->chainStateDir = implode(DIRECTORY_SEPARATOR, [$dataDir, 'chainstate']);
47+
$this->chainstateDir = implode(DIRECTORY_SEPARATOR, [$dataDir, 'chainstate']);
4848
}
4949

5050
/**
@@ -63,11 +63,11 @@ public function getIndex(): Index
6363
}
6464

6565
/**
66-
* @return ChainStateReader
66+
* @return ChainstateReader
6767
*/
68-
public function getChainState(): ChainStateReader
68+
public function getChainstate(): ChainstateReader
6969
{
70-
return new ChainStateReader($this->chainStateDir);
70+
return new ChainstateReader($this->chainstateDir);
7171
}
7272

7373
/**
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
use AndKom\BCDataStream\Reader;
88

99
/**
10-
* Class ChainStateReader
10+
* Class ChainstateReader
1111
* @package AndKom\PhpBitcoinBlockchain
1212
*/
13-
class ChainStateReader
13+
class ChainstateReader
1414
{
1515
const PREFIX_COIN = 'C';
1616
const KEY_BEST_BLOCK = 'B';
@@ -19,7 +19,7 @@ class ChainStateReader
1919
/**
2020
* @var string
2121
*/
22-
protected $chainStateDir;
22+
protected $chainstateDir;
2323

2424
/**
2525
* @var \LevelDB
@@ -32,12 +32,12 @@ class ChainStateReader
3232
protected $obfuscateKey;
3333

3434
/**
35-
* ChainStateReader constructor.
36-
* @param string $chainStateDir
35+
* ChainstateReader constructor.
36+
* @param string $chainstateDir
3737
*/
38-
public function __construct(string $chainStateDir = '')
38+
public function __construct(string $chainstateDir = '')
3939
{
40-
$this->chainStateDir = $chainStateDir;
40+
$this->chainstateDir = $chainstateDir;
4141
}
4242

4343
/**
@@ -49,11 +49,11 @@ protected function openDb(): \LevelDB
4949
return $this->db;
5050
}
5151

52-
return $this->db = new \LevelDB($this->chainStateDir);
52+
return $this->db = new \LevelDB($this->chainstateDir);
5353
}
5454

5555
/**
56-
* @return ChainStateReader
56+
* @return ChainstateReader
5757
*/
5858
protected function closeDb(): self
5959
{
@@ -145,7 +145,7 @@ public function read(): \Generator
145145
throw new Exception('Extension leveldb is not installed.');
146146
}
147147

148-
$db = new \LevelDB($this->chainStateDir);
148+
$db = new \LevelDB($this->chainstateDir);
149149

150150
foreach ($db->getIterator() as $key => $value) {
151151
$key = new Reader($key);

0 commit comments

Comments
 (0)