Gav Wood
11 years ago
8 changed files with 204 additions and 90 deletions
@ -0,0 +1,40 @@ |
|||
/*
|
|||
This file is part of cpp-ethereum. |
|||
|
|||
cpp-ethereum is free software: you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation, either version 3 of the License, or |
|||
(at your option) any later version. |
|||
|
|||
cpp-ethereum is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License |
|||
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
/** @file BlockDetails.cpp
|
|||
* @author Gav Wood <i@gavwood.com> |
|||
* @date 2014 |
|||
*/ |
|||
|
|||
#include "BlockDetails.h" |
|||
|
|||
#include <libethential/Common.h> |
|||
using namespace std; |
|||
using namespace eth; |
|||
|
|||
BlockDetails::BlockDetails(RLP const& _r) |
|||
{ |
|||
number = _r[0].toInt<uint>(); |
|||
totalDifficulty = _r[1].toInt<u256>(); |
|||
parent = _r[2].toHash<h256>(); |
|||
children = _r[3].toVector<h256>(); |
|||
bloom = _r[4].toHash<h256>(); |
|||
} |
|||
|
|||
bytes BlockDetails::rlp() const |
|||
{ |
|||
return rlpList(number, totalDifficulty, parent, children, bloom); |
|||
} |
@ -0,0 +1,76 @@ |
|||
/*
|
|||
This file is part of cpp-ethereum. |
|||
|
|||
cpp-ethereum is free software: you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation, either version 3 of the License, or |
|||
(at your option) any later version. |
|||
|
|||
cpp-ethereum is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License |
|||
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
/** @file BlockDetails.h
|
|||
* @author Gav Wood <i@gavwood.com> |
|||
* @date 2014 |
|||
*/ |
|||
|
|||
#pragma once |
|||
|
|||
#include <libethential/Log.h> |
|||
#include <libethential/RLP.h> |
|||
#include "Manifest.h" |
|||
namespace ldb = leveldb; |
|||
|
|||
namespace eth |
|||
{ |
|||
|
|||
struct BlockDetails |
|||
{ |
|||
BlockDetails(): number(0), totalDifficulty(0) {} |
|||
BlockDetails(uint _n, u256 _tD, h256 _p, h256s _c, h256 _bloom): number(_n), totalDifficulty(_tD), parent(_p), children(_c), bloom(_bloom) {} |
|||
BlockDetails(RLP const& _r); |
|||
bytes rlp() const; |
|||
|
|||
bool isNull() const { return !totalDifficulty; } |
|||
explicit operator bool() const { return !isNull(); } |
|||
|
|||
uint number; // TODO: remove?
|
|||
u256 totalDifficulty; |
|||
h256 parent; |
|||
h256s children; |
|||
h256 bloom; |
|||
}; |
|||
|
|||
struct BlockBlooms |
|||
{ |
|||
BlockBlooms() {} |
|||
BlockBlooms(RLP const& _r) { blooms = _r.toVector<h256>(); } |
|||
bytes rlp() const { RLPStream s; s << blooms; return s.out(); } |
|||
|
|||
h256s blooms; |
|||
}; |
|||
|
|||
struct BlockTraces |
|||
{ |
|||
BlockTraces() {} |
|||
BlockTraces(RLP const& _r) { for (auto const& i: _r) traces.emplace_back(i.data()); } |
|||
bytes rlp() const { RLPStream s(traces.size()); for (auto const& i: traces) i.streamOut(s); return s.out(); } |
|||
|
|||
Manifests traces; |
|||
}; |
|||
|
|||
|
|||
typedef std::map<h256, BlockDetails> BlockDetailsHash; |
|||
typedef std::map<h256, BlockBlooms> BlockBloomsHash; |
|||
typedef std::map<h256, BlockTraces> BlockTracesHash; |
|||
|
|||
static const BlockDetails NullBlockDetails; |
|||
static const BlockBlooms NullBlockBlooms; |
|||
static const BlockTraces NullBlockTraces; |
|||
|
|||
} |
@ -0,0 +1,29 @@ |
|||
/*
|
|||
This file is part of cpp-ethereum. |
|||
|
|||
cpp-ethereum is free software: you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation, either version 3 of the License, or |
|||
(at your option) any later version. |
|||
|
|||
cpp-ethereum is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License |
|||
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
/** @file Guards.cpp
|
|||
* @author Gav Wood <i@gavwood.com> |
|||
* @date 2014 |
|||
*/ |
|||
|
|||
#include "Guards.h" |
|||
using namespace std; |
|||
using namespace eth; |
|||
|
|||
namespace eth |
|||
{ |
|||
|
|||
} |
@ -0,0 +1,34 @@ |
|||
/*
|
|||
This file is part of cpp-ethereum. |
|||
|
|||
cpp-ethereum is free software: you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation, either version 3 of the License, or |
|||
(at your option) any later version. |
|||
|
|||
cpp-ethereum is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License |
|||
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
/** @file Guards.h
|
|||
* @author Gav Wood <i@gavwood.com> |
|||
* @date 2014 |
|||
*/ |
|||
|
|||
#pragma once |
|||
|
|||
#include <boost/thread.hpp> |
|||
|
|||
namespace eth |
|||
{ |
|||
|
|||
using ReadGuard = boost::shared_lock<boost::shared_mutex>; |
|||
using UpgradableGuard = boost::upgrade_lock<boost::shared_mutex>; |
|||
using UpgradeGuard = boost::upgrade_to_unique_lock<boost::shared_mutex>; |
|||
using WriteGuard = boost::unique_lock<boost::shared_mutex>; |
|||
|
|||
} |
Loading…
Reference in new issue