Exemple #1
0
func (db *unspentDb) dbN(i int) *qdb.DB {
	if db.tdb[i] == nil {
		qdb.NewDBrowse(&db.tdb[i], db.dir+fmt.Sprintf("%06d", i), func(k qdb.KeyType, v []byte) uint32 {
			if db.ch.CB.LoadWalk != nil {
				db.ch.CB.LoadWalk(db.tdb[i], k, NewWalkRecord(v))
			}
			if stealthIndex(v) {
				return qdb.YES_BROWSE | qdb.YES_CACHE // stealth output description
			} else if binary.LittleEndian.Uint32(v[44:48]) <= db.noCacheBefore {
				return qdb.NO_CACHE | qdb.NO_BROWSE
			} else if binary.LittleEndian.Uint64(v[36:44]) < MinBrowsableOutValue {
				return qdb.NO_CACHE | qdb.NO_BROWSE
			} else if btc.IsUsefullOutScript(v[SCR_OFFS:]) {
				return qdb.YES_BROWSE | qdb.YES_CACHE // if it was non-browsable, make it such now
			} else {
				return qdb.NO_CACHE | qdb.NO_BROWSE // useluess output - do not waste mem for it
			}
		}, SingeIndexSize)

		if db.nosyncinprogress {
			db.tdb[i].NoSync()
		}
	}
	return db.tdb[i]
}
Exemple #2
0
func (db *UnspentDB) dbN(i int) *qdb.DB {
	if db.tdb[i] == nil {
		qdb.NewDBrowse(&db.tdb[i], db.dir+fmt.Sprintf("%06d", i), func(k qdb.KeyType, v []byte) uint32 {
			if db.ch.CB.LoadWalk != nil {
				db.ch.CB.LoadWalk(NewQdbRecStatic(k, v))
			}
			return 0
		}, 200000 /*size of pre-allocated map*/)

		if db.nosyncinprogress {
			db.tdb[i].NoSync()
		}
	}
	return db.tdb[i]
}