FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
BitShares/src/difficulty.cpp at master · Xenland/BitShares · GitHub
Xenland
BitShares
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
BitShares
/
src
/
difficulty.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
31 lines (26 loc) · 739 Bytes
Breadcrumbs
BitShares
/
src
/
difficulty.cpp
Copy path
File metadata and controls
31 lines (26 loc) · 739 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#
include
<
bts/difficulty.hpp
>
#
include
<
fc/exception/exception.hpp
>
#
include
<
string.h
>
namespace
bts
{
const
fc::bigint&
max224
()
{
static
fc::bigint m = [](){
char
data[
224
/
8
+
1
];
memset
( data,
0xff
,
sizeof
(data) );
data[
0
] =
0
;
return
fc::bigint
(data,
sizeof
(data));
}();
return
m;
}
uint64_t
difficulty
(
const
fc::sha224& hash_value )
{
if
( hash_value ==
fc::sha224
() )
return
uint64_t
(-
1
);
//
div by 0
auto
dif =
max224
() /
fc::bigint
( (
char
*)&hash_value,
sizeof
(hash_value) );
//
TODO... restore this dif >>= 24;
int64_t
tmp = dif.
to_int64
();
//
possible if hash_value starts with 1
if
( tmp <
0
) tmp =
0
;
return
tmp;
}
}
//
bts
Back
|
FazBrowse Home
|
New Git URL