-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBRChainParams.h
109 lines (93 loc) · 3.86 KB
/
BRChainParams.h
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
//
// BRChainParams.h
//
// Created by Aaron Voisine on 1/10/18.
// Copyright (c) 2019 breadwallet LLC
//
// 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 BRChainParams_h
#define BRChainParams_h
#include "BRMerkleBlock.h"
#include "BRSet.h"
#include <assert.h>
typedef struct {
uint32_t height;
UInt256 hash;
uint32_t timestamp;
uint32_t target;
} BRCheckPoint;
typedef struct {
const char * const *dnsSeeds; // NULL terminated array of dns seeds
uint16_t standardPort;
uint32_t magicNumber;
uint64_t services;
int (*verifyDifficulty)(const BRMerkleBlock *block, const BRSet *blockSet); // blockSet must have last 2016 blocks
const BRCheckPoint *checkpoints;
size_t checkpointsCount;
} BRChainParams;
static const char *BRMainNetDNSSeeds[] = {
"dnsseed.ideavis.io", NULL};
static const char *BRTestNetDNSSeeds[] = {
"dnsseed.ideavis.io", NULL
};
// blockchain checkpoints - these are also used as starting points for partial chain downloads, so they must be at
// difficulty transition boundaries in order to verify the block difficulty at the immediately following transition
static const BRCheckPoint BRMainNetCheckpoints[] = {
{ 0, "9718937e6208fd2f310cd3e2a7b67ceff2fda0ac4bff443d7f655b7105500cfd", 1513931142, 0x1e0ffff0 },
};
static const BRCheckPoint BRTestNetCheckpoints[] = {
{ 0, "9718937e6208fd2f310cd3e2a7b67ceff2fda0ac4bff443d7f655b7105500cfd", 1513931142, 0x1e0ffff0 },
};
static int BRMainNetVerifyDifficulty(const BRMerkleBlock *block, const BRSet *blockSet)
{
// const BRMerkleBlock *previous, *b = NULL;
// uint32_t i;
// assert(block != NULL);
// assert(blockSet != NULL);
// // check if we hit a difficulty transition, and find previous transition block
// if ((block->height % BLOCK_DIFFICULTY_INTERVAL) == 0) {
// for (i = 0, b = block; b && i < BLOCK_DIFFICULTY_INTERVAL; i++) {
// b = BRSetGet(blockSet, &b->prevBlock);
// }
// }
// previous = BRSetGet(blockSet, &block->prevBlock);
// return BRMerkleBlockVerifyDifficulty(block, previous, (b) ? b->timestamp : 0);
return 1;
}
static int BRTestNetVerifyDifficulty(const BRMerkleBlock *block, const BRSet *blockSet)
{
return 1; // XXX skip testnet difficulty check for now
}
static const BRChainParams BRMainNetParams = {
BRMainNetDNSSeeds,
9433, // standardPort
0xdbb6c0fb, // magicNumber
0, // services
BRMainNetVerifyDifficulty,
BRMainNetCheckpoints,
sizeof(BRMainNetCheckpoints) / sizeof(*BRMainNetCheckpoints)};
static const BRChainParams BRTestNetParams = {
BRTestNetDNSSeeds,
9433, // standardPort
0xdbb6c0fb, // magicNumber
0, // services
BRTestNetVerifyDifficulty,
BRTestNetCheckpoints,
sizeof(BRTestNetCheckpoints) / sizeof(*BRTestNetCheckpoints)};
#endif // BRChainParams_h