Skip to content

Commit

Permalink
Merge pull request #522 from dashpay/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
pankcuf authored Nov 24, 2023
2 parents c553d04 + 101cfe6 commit bdbe18a
Show file tree
Hide file tree
Showing 83 changed files with 1,666 additions and 886 deletions.
2 changes: 1 addition & 1 deletion DashSync.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Pod::Spec.new do |s|
s.ios.framework = 'UIKit'
s.macos.framework = 'Cocoa'
s.compiler_flags = '-Wno-comma'
s.dependency 'DashSharedCore', '0.4.11'
s.dependency 'DashSharedCore', '0.4.15'
s.dependency 'CocoaLumberjack', '3.7.2'
s.ios.dependency 'DWAlertController', '0.2.1'
s.dependency 'DSDynamicOptions', '0.1.2'
Expand Down
1 change: 1 addition & 0 deletions DashSync/shared/Categories/NSData/NSData+Dash.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ size_t chacha20Poly1305AEADDecrypt(void *_Nullable out, size_t outLen, const voi
- (uint32_t)UInt32AtOffset:(NSUInteger)offset;
- (uint32_t)UInt32BigToHostAtOffset:(NSUInteger)offset;
- (uint64_t)UInt64AtOffset:(NSUInteger)offset;
- (int64_t)Int64AtOffset:(NSUInteger)offset;
- (UInt128)UInt128AtOffset:(NSUInteger)offset;
- (UInt160)UInt160AtOffset:(NSUInteger)offset;
- (UInt256)UInt256AtOffset:(NSUInteger)offset;
Expand Down
5 changes: 5 additions & 0 deletions DashSync/shared/Categories/NSData/NSData+Dash.m
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,11 @@ - (uint64_t)UInt64AtOffset:(NSUInteger)offset {
return CFSwapInt64LittleToHost(*(const uint64_t *)((const uint8_t *)self.bytes + offset));
}

- (int64_t)Int64AtOffset:(NSUInteger)offset {
if (self.length < offset + sizeof(int64_t)) return 0;
return CFSwapInt64LittleToHost(*(const int64_t *)((const uint8_t *)self.bytes + offset));
}

- (UInt128)UInt128AtOffset:(NSUInteger)offset {
if (self.length < offset + sizeof(UInt128)) return UINT128_ZERO;
return *(UInt128 *)(self.bytes + offset);
Expand Down
2 changes: 1 addition & 1 deletion DashSync/shared/Categories/NSData/NSMutableData+Dash.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static void secureDeallocate(void *ptr, void *info) {
}

// Since iOS does not page memory to storage, all we need to do is cleanse allocated memory prior to deallocation.
CFAllocatorRef SecureAllocator() {
CFAllocatorRef SecureAllocator(void) {
static CFAllocatorRef alloc = NULL;
static dispatch_once_t onceToken = 0;

Expand Down
2 changes: 1 addition & 1 deletion DashSync/shared/DashSync.xcdatamodeld/.xccurrentversion
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<plist version="1.0">
<dict>
<key>_XCCurrentVersionName</key>
<string>DashSync 19.xcdatamodel</string>
<string>DashSync 20.xcdatamodel</string>
</dict>
</plist>
518 changes: 518 additions & 0 deletions DashSync/shared/DashSync.xcdatamodeld/DashSync 20.xcdatamodel/contents

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions DashSync/shared/Libraries/DSLogger.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@

NS_ASSUME_NONNULL_BEGIN

@interface NoTimestampLogFormatter : NSObject <DDLogFormatter>
@end
@implementation NoTimestampLogFormatter
- (nullable NSString *)formatLogMessage:(DDLogMessage *)logMessage {
return logMessage.message;
}
@end

@interface DSLogger ()

@property (readonly, nonatomic, strong) DDFileLogger *fileLogger;
Expand All @@ -44,6 +52,7 @@ - (instancetype)init {
DDFileLogger *fileLogger = [[DDFileLogger alloc] init];
fileLogger.rollingFrequency = 60 * 60 * 24; // 24 hour rolling
fileLogger.logFileManager.maximumNumberOfLogFiles = 3; // keep a 3 days worth of log files
//[fileLogger setLogFormatter:[[NoTimestampLogFormatter alloc] init]]; // Use the custom formatter
[DDLog addLogger:fileLogger];
_fileLogger = fileLogger;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ - (NSTimeInterval)timeIntervalAndCalculateNext {

#define EXPT_MODULO ((u_int32_t)RAND_MAX)
#define EXPT_MODULO_F64 ((double)(EXPT_MODULO))
NS_INLINE double SPTExptRandom() {
NS_INLINE double SPTExptRandom(void) {
// We need [0, 1) interval
return arc4random_uniform(EXPT_MODULO);
}
Expand Down
8 changes: 4 additions & 4 deletions DashSync/shared/Models/Chain/DSBlock.m
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ - (BOOL)canCalculateDifficultyWithPreviousBlocks:(NSDictionary *)previousBlocks
}
currentBlock = previousBlocks[uint256_obj(currentBlock.prevBlock)];
if (!currentBlock) {
DSLog(@"Could not retrieve previous block");
DSLog(@"[%@] Could not retrieve previous block", self.chain.name);
return FALSE;
}
}
Expand All @@ -150,7 +150,7 @@ - (BOOL)verifyDifficultyWithPreviousBlocks:(NSDictionary *)previousBlocks rDiffi
}
int32_t diff = self.target - darkGravityWaveTarget;
if (abs(diff) > 1) {
DSLog(@"weird difficulty for block at height %u with target %@ (off by %u)", self.height, uint256_hex(setCompactBE(self.target)), diff);
DSLog(@"[%@] weird difficulty for block at height %u with target %@ (off by %u)", self.chain.name, self.height, uint256_hex(setCompactBE(self.target)), diff);
}
return (abs(diff) < 2); //the core client is less precise with a rounding error that can sometimes cause a problem. We are very rarely 1 off
}
Expand All @@ -173,7 +173,7 @@ - (int32_t)darkGravityWaveTargetWithPreviousBlocks:(NSDictionary *)previousBlock
if (self.chain.allowMinDifficultyBlocks) {
// recent block is more than 2 hours old
if (self.timestamp > (previousBlock.timestamp + 2 * 60 * 60)) {
DSLog(@"Our block is way ahead of previous block %d > %d", self.timestamp, previousBlock.timestamp);
DSLog(@"[%@] Our block is way ahead of previous block %d > %d", self.chain.name, self.timestamp, previousBlock.timestamp);
return self.chain.maxProofOfWorkTarget;
}
// recent block is more than 10 minutes old
Expand Down Expand Up @@ -218,7 +218,7 @@ - (int32_t)darkGravityWaveTargetWithPreviousBlocks:(NSDictionary *)previousBlock
DSBlock *oldCurrentBlock = currentBlock;
currentBlock = previousBlocks[uint256_obj(currentBlock.prevBlock)];
if (!currentBlock) {
DSLog(@"Block %d missing for dark gravity wave calculation", oldCurrentBlock.height - 1);
DSLog(@"[%@] Block %d missing for dark gravity wave calculation", self.chain.name, oldCurrentBlock.height - 1);
}
}
UInt256 blockCount256 = ((UInt256){.u64 = {blockCount, 0, 0, 0}});
Expand Down
2 changes: 2 additions & 0 deletions DashSync/shared/Models/Chain/DSChain.h
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,8 @@ typedef NS_ENUM(uint16_t, DSChainSyncPhase)
- (BOOL)isEvolutionEnabled;
- (BOOL)isDevnetWithGenesisHash:(UInt256)genesisHash;
- (BOOL)isCore19Active;
- (BOOL)isCore20Active;
- (BOOL)isCore20ActiveAtHeight:(uint32_t)height;
- (KeyKind)activeBLSType;

@end
Expand Down
Loading

0 comments on commit bdbe18a

Please sign in to comment.