Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tom
crown-core
Commits
77d6e60d
Commit
77d6e60d
authored
10 years ago
by
Wladimir J. van der Laan
Committed by
infernoman
8 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Add conversion functions arith_uint256<->uint_256
parent
a0b7f2d1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/arith_uint256.cpp
+16
-0
src/arith_uint256.cpp
src/arith_uint256.h
+7
-0
src/arith_uint256.h
with
23 additions
and
0 deletions
+23
-0
src/arith_uint256.cpp
View file @
77d6e60d
...
...
@@ -5,6 +5,7 @@
#include "arith_uint256.h"
#include "uint256.h"
#include "utilstrencodings.h"
#include <stdio.h>
...
...
@@ -355,3 +356,18 @@ uint64_t arith_uint256::GetHash(const arith_uint256& salt) const
return
((((
uint64_t
)
b
)
<<
32
)
|
c
);
}
uint256
ArithToUint256
(
const
arith_uint256
&
a
)
{
uint256
b
;
// TODO: needs bswap32 on big-endian
memcpy
(
b
.
begin
(),
a
.
pn
,
a
.
size
());
return
b
;
}
arith_uint256
UintToArith256
(
const
uint256
&
a
)
{
arith_uint256
b
;
// TODO: needs bswap32 on big-endian
memcpy
(
b
.
pn
,
a
.
begin
(),
a
.
size
());
return
b
;
}
This diff is collapsed.
Click to expand it.
src/arith_uint256.h
View file @
77d6e60d
...
...
@@ -13,6 +13,8 @@
#include <string>
#include <vector>
class
uint256
;
class
uint_error
:
public
std
::
runtime_error
{
public:
explicit
uint_error
(
const
std
::
string
&
str
)
:
std
::
runtime_error
(
str
)
{}
...
...
@@ -349,6 +351,9 @@ public:
uint32_t
GetCompact
(
bool
fNegative
=
false
)
const
;
uint64_t
GetHash
(
const
arith_uint256
&
salt
)
const
;
friend
uint256
ArithToUint256
(
const
arith_uint256
&
);
friend
arith_uint256
UintToArith256
(
const
uint256
&
);
};
/** 512-bit unsigned big integer. */
...
...
@@ -369,5 +374,7 @@ public:
return
ret
;
}
};
uint256
ArithToUint256
(
const
arith_uint256
&
);
arith_uint256
UintToArith256
(
const
uint256
&
);
#endif // BITCOIN_UINT256_H
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment