Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13115014
core_memusage.h
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
core_memusage.h
View Options
// Copyright (c) 2015-2016 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_CORE_MEMUSAGE_H
#define BITCOIN_CORE_MEMUSAGE_H
#include
<memusage.h>
#include
<primitives/block.h>
#include
<primitives/transaction.h>
static
inline
size_t
RecursiveDynamicUsage
(
const
CScript
&
script
)
{
return
memusage
::
DynamicUsage
(
*
static_cast
<
const
CScriptBase
*>
(
&
script
));
}
static
inline
size_t
RecursiveDynamicUsage
(
const
COutPoint
&
out
)
{
return
0
;
}
static
inline
size_t
RecursiveDynamicUsage
(
const
CTxIn
&
in
)
{
return
RecursiveDynamicUsage
(
in
.
scriptSig
)
+
RecursiveDynamicUsage
(
in
.
prevout
);
}
static
inline
size_t
RecursiveDynamicUsage
(
const
CTxOut
&
out
)
{
return
RecursiveDynamicUsage
(
out
.
scriptPubKey
);
}
static
inline
size_t
RecursiveDynamicUsage
(
const
CTransaction
&
tx
)
{
size_t
mem
=
memusage
::
DynamicUsage
(
tx
.
vin
)
+
memusage
::
DynamicUsage
(
tx
.
vout
);
for
(
std
::
vector
<
CTxIn
>::
const_iterator
it
=
tx
.
vin
.
begin
();
it
!=
tx
.
vin
.
end
();
it
++
)
{
mem
+=
RecursiveDynamicUsage
(
*
it
);
}
for
(
std
::
vector
<
CTxOut
>::
const_iterator
it
=
tx
.
vout
.
begin
();
it
!=
tx
.
vout
.
end
();
it
++
)
{
mem
+=
RecursiveDynamicUsage
(
*
it
);
}
return
mem
;
}
static
inline
size_t
RecursiveDynamicUsage
(
const
CMutableTransaction
&
tx
)
{
size_t
mem
=
memusage
::
DynamicUsage
(
tx
.
vin
)
+
memusage
::
DynamicUsage
(
tx
.
vout
);
for
(
std
::
vector
<
CTxIn
>::
const_iterator
it
=
tx
.
vin
.
begin
();
it
!=
tx
.
vin
.
end
();
it
++
)
{
mem
+=
RecursiveDynamicUsage
(
*
it
);
}
for
(
std
::
vector
<
CTxOut
>::
const_iterator
it
=
tx
.
vout
.
begin
();
it
!=
tx
.
vout
.
end
();
it
++
)
{
mem
+=
RecursiveDynamicUsage
(
*
it
);
}
return
mem
;
}
template
<
typename
X
>
static
inline
size_t
RecursiveDynamicUsage
(
const
std
::
shared_ptr
<
X
>
&
p
)
{
return
p
?
memusage
::
DynamicUsage
(
p
)
+
RecursiveDynamicUsage
(
*
p
)
:
0
;
}
#endif
// BITCOIN_CORE_MEMUSAGE_H
File Metadata
Details
Attached
Mime Type
text/x-c++
Expires
Sun, Mar 2, 09:16 (1 d, 4 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5172929
Default Alt Text
core_memusage.h (1 KB)
Attached To
rABC Bitcoin ABC
Event Timeline
Log In to Comment