forked from dogecoinfoundation/libdogecoin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
consensus: add arith_uint256, auxpow, pow, uint256 and validation files
- Loading branch information
Showing
27 changed files
with
1,574 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
The MIT License (MIT) | ||
Copyright (c) 2023 bluezr | ||
Copyright (c) 2023 The Dogecoin Foundation | ||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the "Software"), | ||
to deal in the Software without restriction, including without limitation | ||
the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
and/or sell copies of the Software, and to permit persons to whom the | ||
Software is furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included | ||
in all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES | ||
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
#ifndef __LIBDOGECOIN_ARITH_UINT256_H__ | ||
#define __LIBDOGECOIN_ARITH_UINT256_H__ | ||
|
||
#include <assert.h> | ||
#include <limits.h> | ||
#include <stdint.h> | ||
#include <string.h> | ||
|
||
#include <dogecoin/dogecoin.h> | ||
#include <dogecoin/common.h> | ||
#include <dogecoin/mem.h> | ||
|
||
LIBDOGECOIN_BEGIN_DECL | ||
|
||
struct uint_err { | ||
const char* str; | ||
}; | ||
|
||
typedef struct base_uint_ { | ||
int WIDTH; // BITS / 32 | ||
uint32_t pn[8]; // pn[WIDTH] | ||
} base_uint_; | ||
|
||
typedef base_uint_ arith_uint256; | ||
|
||
arith_uint256 init_arith_uint256(); | ||
arith_uint256 set_compact(arith_uint256 hash, uint32_t compact, dogecoin_bool *pf_negative, dogecoin_bool *pf_overflow); | ||
uint256* arith_to_uint256(const arith_uint256 a); | ||
arith_uint256 uint_to_arith(const uint256* a); | ||
uint64_t get_low64(arith_uint256 pn); | ||
|
||
LIBDOGECOIN_END_DECL | ||
|
||
#endif // __LIBDOGECOIN_ARITH_UINT256_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
The MIT License (MIT) | ||
Copyright (c) 2023 bluezr | ||
Copyright (c) 2023 The Dogecoin Foundation | ||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the "Software"), | ||
to deal in the Software without restriction, including without limitation | ||
the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
and/or sell copies of the Software, and to permit persons to whom the | ||
Software is furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included | ||
in all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES | ||
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
#ifndef __LIBDOGECOIN_AUXPOW__ | ||
#define __LIBDOGECOIN_AUXPOW__ | ||
|
||
#include <dogecoin/block.h> | ||
#include <dogecoin/dogecoin.h> | ||
#include <dogecoin/tx.h> | ||
#include <dogecoin/vector.h> | ||
|
||
LIBDOGECOIN_BEGIN_DECL | ||
|
||
#define BLOCK_VERSION_AUXPOW_BIT 0x100 | ||
|
||
/** Header for merge-mining data in the coinbase. */ | ||
static const unsigned char pchMergedMiningHeader[] = { 0xfa, 0xbe, 'm', 'm' }; | ||
|
||
int get_expected_index(uint32_t nNonce, int nChainId, unsigned h); | ||
uint256* check_merkle_branch(uint256 hash, const vector* parent_coinbase_merkle, int n_index); | ||
void init_aux_pow(dogecoin_block_header* block); | ||
|
||
LIBDOGECOIN_END_DECL | ||
|
||
#endif // __LIBDOGECOIN_AUXPOW__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.