Skip to content

Commit 5e650d6

Browse files
Mike Hearnsipa
authored andcommitted
Import LevelDB 1.5, it will be used for the transaction database.
1 parent 38ac953 commit 5e650d6

130 files changed

Lines changed: 25488 additions & 4 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,20 @@ src/test_bitcoin
1010
*.o
1111
*.patch
1212
.bitcoin
13-
#compilation and Qt preprocessor part
13+
14+
# Compilation and Qt preprocessor part
1415
*.qm
1516
Makefile
1617
bitcoin-qt
17-
#resources cpp
18+
19+
# Resources cpp
1820
qrc_*.cpp
19-
#qt creator
21+
22+
# Qt creator
2023
*.pro.user
21-
#mac specific
24+
25+
# Mac specific
2226
.DS_Store
2327
build
28+
29+
!src/leveldb-*/Makefile

src/leveldb/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
build_config.mk
2+
*.a
3+
*.o
4+
*.dylib*
5+
*.so
6+
*.so.*
7+
*_test
8+
db_bench

src/leveldb/AUTHORS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Names should be added to this file like so:
2+
# Name or Organization <email address>
3+
4+
Google Inc.
5+
6+
# Initial version authors:
7+
Jeffrey Dean <jeff@google.com>
8+
Sanjay Ghemawat <sanjay@google.com>

src/leveldb/LICENSE

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Copyright (c) 2011 The LevelDB Authors. All rights reserved.
2+
3+
Redistribution and use in source and binary forms, with or without
4+
modification, are permitted provided that the following conditions are
5+
met:
6+
7+
* Redistributions of source code must retain the above copyright
8+
notice, this list of conditions and the following disclaimer.
9+
* Redistributions in binary form must reproduce the above
10+
copyright notice, this list of conditions and the following disclaimer
11+
in the documentation and/or other materials provided with the
12+
distribution.
13+
* Neither the name of Google Inc. nor the names of its
14+
contributors may be used to endorse or promote products derived from
15+
this software without specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

src/leveldb/Makefile

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
# Copyright (c) 2011 The LevelDB Authors. All rights reserved.
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file. See the AUTHORS file for names of contributors.
4+
5+
# Inherit some settings from environment variables, if available
6+
INSTALL_PATH ?= $(CURDIR)
7+
8+
#-----------------------------------------------
9+
# Uncomment exactly one of the lines labelled (A), (B), and (C) below
10+
# to switch between compilation modes.
11+
12+
OPT ?= -O2 -DNDEBUG # (A) Production use (optimized mode)
13+
# OPT ?= -g2 # (B) Debug mode, w/ full line-level debugging symbols
14+
# OPT ?= -O2 -g2 -DNDEBUG # (C) Profiling mode: opt, but w/debugging symbols
15+
#-----------------------------------------------
16+
17+
# detect what platform we're building on
18+
$(shell ./build_detect_platform build_config.mk)
19+
# this file is generated by the previous line to set build flags and sources
20+
include build_config.mk
21+
22+
CFLAGS += -I. -I./include $(PLATFORM_CCFLAGS) $(OPT)
23+
CXXFLAGS += -I. -I./include $(PLATFORM_CXXFLAGS) $(OPT)
24+
25+
LDFLAGS += $(PLATFORM_LDFLAGS)
26+
27+
LIBOBJECTS = $(SOURCES:.cc=.o)
28+
MEMENVOBJECTS = $(MEMENV_SOURCES:.cc=.o)
29+
30+
TESTUTIL = ./util/testutil.o
31+
TESTHARNESS = ./util/testharness.o $(TESTUTIL)
32+
33+
TESTS = \
34+
arena_test \
35+
bloom_test \
36+
c_test \
37+
cache_test \
38+
coding_test \
39+
corruption_test \
40+
crc32c_test \
41+
db_test \
42+
dbformat_test \
43+
env_test \
44+
filename_test \
45+
filter_block_test \
46+
log_test \
47+
memenv_test \
48+
skiplist_test \
49+
table_test \
50+
version_edit_test \
51+
version_set_test \
52+
write_batch_test
53+
54+
PROGRAMS = db_bench $(TESTS)
55+
BENCHMARKS = db_bench_sqlite3 db_bench_tree_db
56+
57+
LIBRARY = libleveldb.a
58+
MEMENVLIBRARY = libmemenv.a
59+
60+
default: all
61+
62+
# Should we build shared libraries?
63+
ifneq ($(PLATFORM_SHARED_EXT),)
64+
65+
ifneq ($(PLATFORM_SHARED_VERSIONED),true)
66+
SHARED1 = libleveldb.$(PLATFORM_SHARED_EXT)
67+
SHARED2 = $(SHARED1)
68+
SHARED3 = $(SHARED1)
69+
SHARED = $(SHARED1)
70+
else
71+
# Update db.h if you change these.
72+
SHARED_MAJOR = 1
73+
SHARED_MINOR = 5
74+
SHARED1 = libleveldb.$(PLATFORM_SHARED_EXT)
75+
SHARED2 = $(SHARED1).$(SHARED_MAJOR)
76+
SHARED3 = $(SHARED1).$(SHARED_MAJOR).$(SHARED_MINOR)
77+
SHARED = $(SHARED1) $(SHARED2) $(SHARED3)
78+
$(SHARED1): $(SHARED3)
79+
ln -fs $(SHARED3) $(SHARED1)
80+
$(SHARED2): $(SHARED3)
81+
ln -fs $(SHARED3) $(SHARED2)
82+
endif
83+
84+
$(SHARED3):
85+
$(CXX) $(LDFLAGS) $(PLATFORM_SHARED_LDFLAGS)$(SHARED2) $(CXXFLAGS) $(PLATFORM_SHARED_CFLAGS) $(SOURCES) -o $(SHARED3)
86+
87+
endif # PLATFORM_SHARED_EXT
88+
89+
all: $(SHARED) $(LIBRARY)
90+
91+
check: all $(PROGRAMS) $(TESTS)
92+
for t in $(TESTS); do echo "***** Running $$t"; ./$$t || exit 1; done
93+
94+
clean:
95+
-rm -f $(PROGRAMS) $(BENCHMARKS) $(LIBRARY) $(SHARED) $(MEMENVLIBRARY) */*.o */*/*.o ios-x86/*/*.o ios-arm/*/*.o build_config.mk
96+
-rm -rf ios-x86/* ios-arm/*
97+
98+
$(LIBRARY): $(LIBOBJECTS)
99+
rm -f $@
100+
$(AR) -rs $@ $(LIBOBJECTS)
101+
102+
db_bench: db/db_bench.o $(LIBOBJECTS) $(TESTUTIL)
103+
$(CXX) db/db_bench.o $(LIBOBJECTS) $(TESTUTIL) -o $@ $(LDFLAGS)
104+
105+
db_bench_sqlite3: doc/bench/db_bench_sqlite3.o $(LIBOBJECTS) $(TESTUTIL)
106+
$(CXX) doc/bench/db_bench_sqlite3.o $(LIBOBJECTS) $(TESTUTIL) -o $@ $(LDFLAGS) -lsqlite3
107+
108+
db_bench_tree_db: doc/bench/db_bench_tree_db.o $(LIBOBJECTS) $(TESTUTIL)
109+
$(CXX) doc/bench/db_bench_tree_db.o $(LIBOBJECTS) $(TESTUTIL) -o $@ $(LDFLAGS) -lkyotocabinet
110+
111+
arena_test: util/arena_test.o $(LIBOBJECTS) $(TESTHARNESS)
112+
$(CXX) util/arena_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
113+
114+
bloom_test: util/bloom_test.o $(LIBOBJECTS) $(TESTHARNESS)
115+
$(CXX) util/bloom_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
116+
117+
c_test: db/c_test.o $(LIBOBJECTS) $(TESTHARNESS)
118+
$(CXX) db/c_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
119+
120+
cache_test: util/cache_test.o $(LIBOBJECTS) $(TESTHARNESS)
121+
$(CXX) util/cache_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
122+
123+
coding_test: util/coding_test.o $(LIBOBJECTS) $(TESTHARNESS)
124+
$(CXX) util/coding_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
125+
126+
corruption_test: db/corruption_test.o $(LIBOBJECTS) $(TESTHARNESS)
127+
$(CXX) db/corruption_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
128+
129+
crc32c_test: util/crc32c_test.o $(LIBOBJECTS) $(TESTHARNESS)
130+
$(CXX) util/crc32c_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
131+
132+
db_test: db/db_test.o $(LIBOBJECTS) $(TESTHARNESS)
133+
$(CXX) db/db_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
134+
135+
dbformat_test: db/dbformat_test.o $(LIBOBJECTS) $(TESTHARNESS)
136+
$(CXX) db/dbformat_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
137+
138+
env_test: util/env_test.o $(LIBOBJECTS) $(TESTHARNESS)
139+
$(CXX) util/env_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
140+
141+
filename_test: db/filename_test.o $(LIBOBJECTS) $(TESTHARNESS)
142+
$(CXX) db/filename_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
143+
144+
filter_block_test: table/filter_block_test.o $(LIBOBJECTS) $(TESTHARNESS)
145+
$(CXX) table/filter_block_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
146+
147+
log_test: db/log_test.o $(LIBOBJECTS) $(TESTHARNESS)
148+
$(CXX) db/log_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
149+
150+
table_test: table/table_test.o $(LIBOBJECTS) $(TESTHARNESS)
151+
$(CXX) table/table_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
152+
153+
skiplist_test: db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS)
154+
$(CXX) db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
155+
156+
version_edit_test: db/version_edit_test.o $(LIBOBJECTS) $(TESTHARNESS)
157+
$(CXX) db/version_edit_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
158+
159+
version_set_test: db/version_set_test.o $(LIBOBJECTS) $(TESTHARNESS)
160+
$(CXX) db/version_set_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
161+
162+
write_batch_test: db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS)
163+
$(CXX) db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@ $(LDFLAGS)
164+
165+
$(MEMENVLIBRARY) : $(MEMENVOBJECTS)
166+
rm -f $@
167+
$(AR) -rs $@ $(MEMENVOBJECTS)
168+
169+
memenv_test : helpers/memenv/memenv_test.o $(MEMENVLIBRARY) $(LIBRARY) $(TESTHARNESS)
170+
$(CXX) helpers/memenv/memenv_test.o $(MEMENVLIBRARY) $(LIBRARY) $(TESTHARNESS) -o $@ $(LDFLAGS)
171+
172+
ifeq ($(PLATFORM), IOS)
173+
# For iOS, create universal object files to be used on both the simulator and
174+
# a device.
175+
PLATFORMSROOT=/Applications/Xcode.app/Contents/Developer/Platforms
176+
SIMULATORROOT=$(PLATFORMSROOT)/iPhoneSimulator.platform/Developer
177+
DEVICEROOT=$(PLATFORMSROOT)/iPhoneOS.platform/Developer
178+
IOSVERSION=$(shell defaults read $(PLATFORMSROOT)/iPhoneOS.platform/version CFBundleShortVersionString)
179+
180+
.cc.o:
181+
mkdir -p ios-x86/$(dir $@)
182+
$(SIMULATORROOT)/usr/bin/$(CXX) $(CXXFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 -c $< -o ios-x86/$@
183+
mkdir -p ios-arm/$(dir $@)
184+
$(DEVICEROOT)/usr/bin/$(CXX) $(CXXFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk -arch armv6 -arch armv7 -c $< -o ios-arm/$@
185+
lipo ios-x86/$@ ios-arm/$@ -create -output $@
186+
187+
.c.o:
188+
mkdir -p ios-x86/$(dir $@)
189+
$(SIMULATORROOT)/usr/bin/$(CC) $(CFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 -c $< -o ios-x86/$@
190+
mkdir -p ios-arm/$(dir $@)
191+
$(DEVICEROOT)/usr/bin/$(CC) $(CFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk -arch armv6 -arch armv7 -c $< -o ios-arm/$@
192+
lipo ios-x86/$@ ios-arm/$@ -create -output $@
193+
194+
else
195+
.cc.o:
196+
$(CXX) $(CXXFLAGS) -c $< -o $@
197+
198+
.c.o:
199+
$(CC) $(CFLAGS) -c $< -o $@
200+
endif

src/leveldb/README

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
LevelDB is a third party library used for the transaction database.
2+
It is imported into the Bitcoin codebase due to being relatively new
3+
and not widely packaged.
4+
5+
6+
7+
---------------------------------------------------------------------
8+
9+
leveldb: A key-value store
10+
Authors: Sanjay Ghemawat (sanjay@google.com) and Jeff Dean (jeff@google.com)
11+
12+
The code under this directory implements a system for maintaining a
13+
persistent key/value store.
14+
15+
See doc/index.html for more explanation.
16+
See doc/impl.html for a brief overview of the implementation.
17+
18+
The public interface is in include/*.h. Callers should not include or
19+
rely on the details of any other header files in this package. Those
20+
internal APIs may be changed without warning.
21+
22+
Guide to header files:
23+
24+
include/db.h
25+
Main interface to the DB: Start here
26+
27+
include/options.h
28+
Control over the behavior of an entire database, and also
29+
control over the behavior of individual reads and writes.
30+
31+
include/comparator.h
32+
Abstraction for user-specified comparison function. If you want
33+
just bytewise comparison of keys, you can use the default comparator,
34+
but clients can write their own comparator implementations if they
35+
want custom ordering (e.g. to handle different character
36+
encodings, etc.)
37+
38+
include/iterator.h
39+
Interface for iterating over data. You can get an iterator
40+
from a DB object.
41+
42+
include/write_batch.h
43+
Interface for atomically applying multiple updates to a database.
44+
45+
include/slice.h
46+
A simple module for maintaining a pointer and a length into some
47+
other byte array.
48+
49+
include/status.h
50+
Status is returned from many of the public interfaces and is used
51+
to report success and various kinds of errors.
52+
53+
include/env.h
54+
Abstraction of the OS environment. A posix implementation of
55+
this interface is in util/env_posix.cc
56+
57+
include/table.h
58+
include/table_builder.h
59+
Lower-level modules that most clients probably won't use directly

src/leveldb/TODO

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
ss
2+
- Stats
3+
4+
db
5+
- Maybe implement DB::BulkDeleteForRange(start_key, end_key)
6+
that would blow away files whose ranges are entirely contained
7+
within [start_key..end_key]? For Chrome, deletion of obsolete
8+
object stores, etc. can be done in the background anyway, so
9+
probably not that important.
10+
11+
After a range is completely deleted, what gets rid of the
12+
corresponding files if we do no future changes to that range. Make
13+
the conditions for triggering compactions fire in more situations?

0 commit comments

Comments
 (0)