Skip to content

Commit a1f5b27

Browse files
committed
improve some misleading method names
1 parent 1ede8ad commit a1f5b27

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

src/main/java/prof7bit/bitcoin/wallettool/fileformats/WalletDatHandler.xtend

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class WalletDat {
147147
* method will be called for every key/value pair that is
148148
* found in the database while the database is being read.
149149
*/
150-
private def parseKeyValuePair(ByteBuffer key, ByteBuffer value) {
150+
private def processKeyValuePair(ByteBuffer key, ByteBuffer value) {
151151
if (Arrays.equals(key.array, "main".bytes)){
152152
// ignore this key, it appears on page #1
153153
// as the only item and seems to be some
@@ -316,11 +316,11 @@ class WalletDat {
316316

317317
/**
318318
* Parse the wallet.dat file, find all b-tree leaf
319-
* pages in the file and put all their items into
320-
* the bdbKeyValueItems list. Begin with every root
321-
* leaf and then follow the next_pgno until there is
322-
* no next page. When this function has returned we
323-
* have all key/value items in the bdbKeyValueItems list.
319+
* pages in the file and process all their items.
320+
* Begin with the first leaf page and then follow the
321+
* next_pgno until there is no next page. When this
322+
* function has returned we will have iterated over
323+
* all key/value items in the entire database
324324
*/
325325
private def parseBerkeleyFile() throws Exception {
326326
// these are the only ones we support
@@ -337,19 +337,20 @@ class WalletDat {
337337
val last_pgno = head.lastPgno
338338

339339
for (pgno : 0..last_pgno) {
340-
// find a root leaf
340+
// find all first leaves. Actually there are at
341+
// least 2 trees in every wallet file, so we
342+
// will find two first leaves.
341343
val page = new BerkeleyDBLeafPage(raf, pgno, pagesize)
342-
if (page.isLBTREE && page.isRootPage){
344+
if (page.isLBTREE && page.isFirstLeaf){
343345
readAllLeafPages(page)
344346
}
345347
}
346348
}
347349

348350
/**
349-
* parse this leaf page and all next pages
350-
* as indicated by next_pgno and add all their
351-
* items into the bdbKeyValueItems list until
352-
* there is no next page anymore.
351+
* parse this leaf page and all following leaf pages
352+
* as indicated by next_pgno and process all of their
353+
* items until there is no next page anymore.
353354
*/
354355
private def readAllLeafPages(BerkeleyDBLeafPage root) throws IOException {
355356
var page = root
@@ -360,8 +361,8 @@ class WalletDat {
360361
}
361362

362363
/**
363-
* parse this leaf page and add all
364-
* its items to the bdbKeyValueItems list
364+
* parse this leaf page and iterate over all
365+
* its items, read and process each of them.
365366
*/
366367
private def readLeafPage(BerkeleyDBLeafPage page) {
367368
val count = page.entryCount
@@ -375,7 +376,7 @@ class WalletDat {
375376
} else {
376377
// odd number, item is a value,
377378
// previous item was its key
378-
parseKeyValuePair(currentKey, item)
379+
processKeyValuePair(currentKey, item)
379380
currentKey = null
380381
}
381382
}
@@ -411,7 +412,7 @@ abstract class BerkeleyDBPage {
411412
b.getInt(16)
412413
}
413414

414-
def isRootPage() {
415+
def isFirstLeaf() {
415416
prevPgno == 0
416417
}
417418

0 commit comments

Comments
 (0)