Skip to content

Commit

Permalink
Mobile API implementation
Browse files Browse the repository at this point in the history
api for mobile client
support for openssl 1.1.0+
  • Loading branch information
BixBite-project committed Nov 20, 2018
1 parent 588472e commit 5479cf3
Show file tree
Hide file tree
Showing 1,364 changed files with 260,890 additions and 14,094 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "external/unbound"]
path = external/unbound
url = https://github.com/monero-project/unbound
branch = monero
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ endif()
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
if(MINGW)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wa,-mbig-obj")
set(EXTRA_LIBRARIES mswsock;ws2_32;iphlpapi)
set(EXTRA_LIBRARIES mswsock;ws2_32;crypt32;iphlpapi)
elseif(APPLE OR FREEBSD OR OPENBSD OR ANDROID)
set(EXTRA_LIBRARIES "")
elseif(NOT MSVC)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ BixBite inherited all the best from Sumocoin and intends to organize a faster pa
## Coin Supply & Emission

- **Total supply**: **688 009 000** Bixbite. About ~5% was premined to reserve for future development
- **Coin symbol**: **BXB**
- **Coin symbol**: **bixbite**
- **Hash algorithm**: CryptoNight Heavy (Proof-Of-Work)

## About this Project
Expand Down
1 change: 1 addition & 0 deletions cmake/test-static-assert.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright (c) 2014-2016, The Monero Project
// Copyright (c) 2017-2018, The Bixbite Project
//
// All rights reserved.
//
Expand Down
10 changes: 6 additions & 4 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2014-2016, The Monero Project
# Copyright (c) 2014-2017, The Monero Project
#
# All rights reserved.
#
Expand Down Expand Up @@ -34,11 +34,12 @@
# We always compile if we are building statically to reduce static dependency issues...
# ...except for FreeBSD, because FreeBSD is a special case that doesn't play well with
# others.

find_package(Miniupnpc QUIET)
if(NOT IOS)
find_package(Miniupnpc QUIET)
endif()

# If we have the correct shared version and we're not building static, use it
if(STATIC)
if(STATIC OR IOS)
set(USE_SHARED_MINIUPNPC false)
elseif(MINIUPNP_FOUND AND MINIUPNPC_VERSION_1_7_OR_HIGHER)
set(USE_SHARED_MINIUPNPC true)
Expand Down Expand Up @@ -98,3 +99,4 @@ else()
endif()

add_subdirectory(db_drivers)
add_subdirectory(easylogging++)
15 changes: 10 additions & 5 deletions external/boost/archive/portable_binary_oarchive.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,24 @@ class portable_binary_oarchive_exception :
public boost::archive::archive_exception
{
public:
typedef enum {
enum exception_code {
invalid_flags
} exception_code;
portable_binary_oarchive_exception(exception_code c = invalid_flags )
} m_exception_code ;
portable_binary_oarchive_exception(exception_code c = invalid_flags ) :
boost::archive::archive_exception(boost::archive::archive_exception::other_exception),
m_exception_code(c)
{}
virtual const char *what( ) const throw( )
{
const char *msg = "programmer error";
switch(code){
switch(m_exception_code){
case invalid_flags:
msg = "cannot be both big and little endian";
break;
default:
boost::archive::archive_exception::what();
msg = boost::archive::archive_exception::what();
assert(false);
break;
}
return msg;
}
Expand Down
2 changes: 1 addition & 1 deletion external/db_drivers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2014-2016, The Monero Project
# Copyright (c) 2014-2017, The Monero Project
#
# All rights reserved.
#
Expand Down
23 changes: 23 additions & 0 deletions external/db_drivers/liblmdb/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
mtest
mtest[23456]
testdb
mdb_copy
mdb_stat
mdb_dump
mdb_load
*.lo
*.[ao]
*.so
*.exe
*[~#]
*.bak
*.orig
*.rej
*.gcov
*.gcda
*.gcno
core
core.*
valgrind.*
man/
html/
15 changes: 8 additions & 7 deletions external/db_drivers/liblmdb/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# Copyright (c) 2014-2016, The Monero Project
#
# Copyright (c) 2014-2017, The Monero Project
#
# All rights reserved.
#
#
# Redistribution and use in source and binary forms, with or without modification, are
# permitted provided that the following conditions are met:
#
#
# 1. Redistributions of source code must retain the above copyright notice, this list of
# conditions and the following disclaimer.
#
#
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
# of conditions and the following disclaimer in the documentation and/or other
# materials provided with the distribution.
#
#
# 3. Neither the name of the copyright holder nor the names of its contributors may be
# used to endorse or promote products derived from this software without specific
# prior written permission.
#
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
Expand All @@ -34,6 +34,7 @@ if(ANDROID)
add_definitions("-DANDROID=1")
endif()


set (lmdb_sources
mdb.c
midl.c)
Expand Down
8 changes: 8 additions & 0 deletions external/db_drivers/liblmdb/lmdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ typedef void (MDB_rel_func)(MDB_val *item, void *oldptr, void *newptr, void *rel
#define MDB_NORDAHEAD 0x800000
/** don't initialize malloc'd memory before writing to datafile */
#define MDB_NOMEMINIT 0x1000000
/** use the previous snapshot rather than the latest one */
#define MDB_PREVSNAPSHOT 0x2000000
/** @} */

/** @defgroup mdb_dbi_open Database Flags
Expand Down Expand Up @@ -622,6 +624,12 @@ int mdb_env_create(MDB_env **env);
* caller is expected to overwrite all of the memory that was
* reserved in that case.
* This flag may be changed at any time using #mdb_env_set_flags().
* <li>#MDB_PREVSNAPSHOT
* Open the environment with the previous snapshot rather than the latest
* one. This loses the latest transaction, but may help work around some
* types of corruption. If opened with write access, this must be the
* only process using the environment. This flag is automatically reset
* after a write transaction is successfully committed.
* </ul>
* @param[in] mode The UNIX permissions to set on created files and semaphores.
* This parameter is ignored on Windows.
Expand Down
81 changes: 52 additions & 29 deletions external/db_drivers/liblmdb/mdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,16 @@ typedef struct MDB_txbody {
uint32_t mtb_magic;
/** Format of this lock file. Must be set to #MDB_LOCK_FORMAT. */
uint32_t mtb_format;
/** The ID of the last transaction committed to the database.
* This is recorded here only for convenience; the value can always
* be determined by reading the main database meta pages.
*/
volatile txnid_t mtb_txnid;
/** The number of slots that have been used in the reader table.
* This always records the maximum count, it is not decremented
* when readers release their slots.
*/
volatile unsigned mtb_numreaders;
#if defined(_WIN32) || defined(MDB_USE_POSIX_SEM)
char mtb_rmname[MNAME_LEN];
#elif defined(MDB_USE_SYSV_SEM)
Expand All @@ -820,16 +830,6 @@ typedef struct MDB_txbody {
*/
mdb_mutex_t mtb_rmutex;
#endif
/** The ID of the last transaction committed to the database.
* This is recorded here only for convenience; the value can always
* be determined by reading the main database meta pages.
*/
volatile txnid_t mtb_txnid;
/** The number of slots that have been used in the reader table.
* This always records the maximum count, it is not decremented
* when readers release their slots.
*/
volatile unsigned mtb_numreaders;
} MDB_txbody;

/** The actual reader table definition. */
Expand Down Expand Up @@ -1468,7 +1468,7 @@ static int mdb_page_merge(MDB_cursor *csrc, MDB_cursor *cdst);
static int mdb_page_split(MDB_cursor *mc, MDB_val *newkey, MDB_val *newdata,
pgno_t newpgno, unsigned int nflags);

static int mdb_env_read_header(MDB_env *env, MDB_meta *meta);
static int mdb_env_read_header(MDB_env *env, int prev, MDB_meta *meta);
static MDB_meta *mdb_env_pick_meta(const MDB_env *env);
static int mdb_env_write_meta(MDB_txn *txn);
#ifdef MDB_USE_POSIX_MUTEX /* Drop unused excl arg */
Expand Down Expand Up @@ -1953,13 +1953,15 @@ static void
mdb_cursor_unref(MDB_cursor *mc)
{
int i;
if (!mc->mc_snum || !mc->mc_pg[0] || IS_SUBP(mc->mc_pg[0]))
return;
for (i=0; i<mc->mc_snum; i++)
mdb_page_unref(mc->mc_txn, mc->mc_pg[i]);
if (mc->mc_ovpg) {
mdb_page_unref(mc->mc_txn, mc->mc_ovpg);
mc->mc_ovpg = 0;
if (mc->mc_txn->mt_rpages[0].mid) {
if (!mc->mc_snum || !mc->mc_pg[0] || IS_SUBP(mc->mc_pg[0]))
return;
for (i=0; i<mc->mc_snum; i++)
mdb_page_unref(mc->mc_txn, mc->mc_pg[i]);
if (mc->mc_ovpg) {
mdb_page_unref(mc->mc_txn, mc->mc_ovpg);
mc->mc_ovpg = 0;
}
}
mc->mc_snum = mc->mc_top = 0;
mc->mc_pg[0] = NULL;
Expand Down Expand Up @@ -3630,6 +3632,8 @@ mdb_page_flush(MDB_txn *txn, int keep)
return MDB_SUCCESS;
}

static int ESECT mdb_env_share_locks(MDB_env *env, int *excl);

int
mdb_txn_commit(MDB_txn *txn)
{
Expand Down Expand Up @@ -3852,6 +3856,15 @@ mdb_txn_commit(MDB_txn *txn)
if ((rc = mdb_env_write_meta(txn)))
goto fail;
end_mode = MDB_END_COMMITTED|MDB_END_UPDATE;
if (env->me_flags & MDB_PREVSNAPSHOT) {
if (!(env->me_flags & MDB_NOLOCK)) {
int excl;
rc = mdb_env_share_locks(env, &excl);
if (rc)
goto fail;
}
env->me_flags ^= MDB_PREVSNAPSHOT;
}

done:
mdb_txn_end(txn, end_mode);
Expand All @@ -3865,11 +3878,12 @@ mdb_txn_commit(MDB_txn *txn)
/** Read the environment parameters of a DB environment before
* mapping it into memory.
* @param[in] env the environment handle
* @param[in] prev whether to read the backup meta page
* @param[out] meta address of where to store the meta information
* @return 0 on success, non-zero on failure.
*/
static int ESECT
mdb_env_read_header(MDB_env *env, MDB_meta *meta)
mdb_env_read_header(MDB_env *env, int prev, MDB_meta *meta)
{
MDB_metabuf pbuf;
MDB_page *p;
Expand Down Expand Up @@ -3920,7 +3934,7 @@ mdb_env_read_header(MDB_env *env, MDB_meta *meta)
return MDB_VERSION_MISMATCH;
}

if (off == 0 || m->mm_txnid > meta->mm_txnid)
if (off == 0 || (prev ? m->mm_txnid < meta->mm_txnid : m->mm_txnid > meta->mm_txnid))
*meta = *m;
}
return 0;
Expand Down Expand Up @@ -4129,7 +4143,8 @@ static MDB_meta *
mdb_env_pick_meta(const MDB_env *env)
{
MDB_meta *const *metas = env->me_metas;
return metas[ metas[0]->mm_txnid < metas[1]->mm_txnid ];
return metas[ (metas[0]->mm_txnid < metas[1]->mm_txnid) ^
((env->me_flags & MDB_PREVSNAPSHOT) != 0) ];
}

int ESECT
Expand Down Expand Up @@ -4364,7 +4379,7 @@ mdb_fsize(HANDLE fd, mdb_size_t *size)
/** Further setup required for opening an LMDB environment
*/
static int ESECT
mdb_env_open2(MDB_env *env)
mdb_env_open2(MDB_env *env, int prev)
{
unsigned int flags = env->me_flags;
int i, newenv = 0, rc;
Expand Down Expand Up @@ -4427,7 +4442,7 @@ mdb_env_open2(MDB_env *env)
}
#endif

if ((i = mdb_env_read_header(env, &meta)) != 0) {
if ((i = mdb_env_read_header(env, prev, &meta)) != 0) {
if (i != ENOENT)
return i;
DPUTS("new mdbenv");
Expand Down Expand Up @@ -4503,6 +4518,9 @@ mdb_env_open2(MDB_env *env)
#endif
env->me_maxpg = env->me_mapsize / env->me_psize;

if (env->me_txns)
env->me_txns->mti_txnid = meta.mm_txnid;

#if MDB_DEBUG
{
MDB_meta *meta = mdb_env_pick_meta(env);
Expand Down Expand Up @@ -4598,9 +4616,6 @@ static int ESECT
mdb_env_share_locks(MDB_env *env, int *excl)
{
int rc = 0;
MDB_meta *meta = mdb_env_pick_meta(env);

env->me_txns->mti_txnid = meta->mm_txnid;

#ifdef _WIN32
{
Expand Down Expand Up @@ -5054,7 +5069,7 @@ mdb_env_setup_locks(MDB_env *env, char *lpath, int mode, int *excl)
*/
#define CHANGEABLE (MDB_NOSYNC|MDB_NOMETASYNC|MDB_MAPASYNC|MDB_NOMEMINIT)
#define CHANGELESS (MDB_FIXEDMAP|MDB_NOSUBDIR|MDB_RDONLY| \
MDB_WRITEMAP|MDB_NOTLS|MDB_NOLOCK|MDB_NORDAHEAD)
MDB_WRITEMAP|MDB_NOTLS|MDB_NOLOCK|MDB_NORDAHEAD|MDB_PREVSNAPSHOT)

#if VALID_FLAGS & PERSISTENT_FLAGS & (CHANGEABLE|CHANGELESS)
# error "Persistent DB flags & env flags overlap, but both go in mm_flags"
Expand Down Expand Up @@ -5176,9 +5191,13 @@ mdb_env_open(MDB_env *env, const char *path, unsigned int flags, mdb_mode_t mode
rc = mdb_env_setup_locks(env, lpath, mode, &excl);
if (rc)
goto leave;
if ((flags & MDB_PREVSNAPSHOT) && !excl) {
rc = EAGAIN;
goto leave;
}
}

if ((rc = mdb_env_open2(env)) == MDB_SUCCESS) {
if ((rc = mdb_env_open2(env, flags & MDB_PREVSNAPSHOT)) == MDB_SUCCESS) {
if (flags & (MDB_RDONLY|MDB_WRITEMAP)) {
env->me_mfd = env->me_fd;
} else {
Expand All @@ -5204,7 +5223,7 @@ mdb_env_open(MDB_env *env, const char *path, unsigned int flags, mdb_mode_t mode
}
}
DPRINTF(("opened dbenv %p", (void *) env));
if (excl > 0) {
if (excl > 0 && !(flags & MDB_PREVSNAPSHOT)) {
rc = mdb_env_share_locks(env, &excl);
if (rc)
goto leave;
Expand Down Expand Up @@ -6269,6 +6288,10 @@ mdb_ovpage_free(MDB_cursor *mc, MDB_page *mp)
if (rc)
return rc;
}
#ifdef MDB_VL32
if (mc->mc_ovpg == mp)
mc->mc_ovpg = NULL;
#endif
mc->mc_db->md_overflow_pages -= ovpages;
return 0;
}
Expand Down
Loading

0 comments on commit 5479cf3

Please sign in to comment.