@@ -52,7 +52,7 @@ public MoneroBlockHeader(MoneroBlockHeader header)
5252
5353 public virtual MoneroBlockHeader SetHash ( string ? hash )
5454 {
55- this . _hash = hash ;
55+ _hash = hash ;
5656 return this ;
5757 }
5858
@@ -63,7 +63,7 @@ public virtual MoneroBlockHeader SetHash(string? hash)
6363
6464 public virtual MoneroBlockHeader SetHeight ( ulong ? height )
6565 {
66- this . _height = height ;
66+ _height = height ;
6767 return this ;
6868 }
6969
@@ -74,7 +74,7 @@ public virtual MoneroBlockHeader SetHeight(ulong? height)
7474
7575 public virtual MoneroBlockHeader SetTimestamp ( ulong ? timestamp )
7676 {
77- this . _timestamp = timestamp ;
77+ _timestamp = timestamp ;
7878 return this ;
7979 }
8080
@@ -85,7 +85,7 @@ public virtual MoneroBlockHeader SetTimestamp(ulong? timestamp)
8585
8686 public virtual MoneroBlockHeader SetSize ( ulong ? size )
8787 {
88- this . _size = size ;
88+ _size = size ;
8989 return this ;
9090 }
9191
@@ -96,7 +96,7 @@ public virtual MoneroBlockHeader SetSize(ulong? size)
9696
9797 public virtual MoneroBlockHeader SetWeight ( ulong ? weight )
9898 {
99- this . _weight = weight ;
99+ _weight = weight ;
100100 return this ;
101101 }
102102
@@ -107,7 +107,7 @@ public virtual MoneroBlockHeader SetWeight(ulong? weight)
107107
108108 public virtual MoneroBlockHeader SetLongTermWeight ( ulong ? longTermWeight )
109109 {
110- this . _longTermWeight = longTermWeight ;
110+ _longTermWeight = longTermWeight ;
111111 return this ;
112112 }
113113
@@ -118,7 +118,7 @@ public virtual MoneroBlockHeader SetLongTermWeight(ulong? longTermWeight)
118118
119119 public virtual MoneroBlockHeader SetDepth ( ulong ? depth )
120120 {
121- this . _depth = depth ;
121+ _depth = depth ;
122122 return this ;
123123 }
124124
@@ -129,7 +129,7 @@ public virtual MoneroBlockHeader SetDepth(ulong? depth)
129129
130130 public virtual MoneroBlockHeader SetDifficulty ( ulong ? difficulty )
131131 {
132- this . _difficulty = difficulty ;
132+ _difficulty = difficulty ;
133133 return this ;
134134 }
135135
@@ -140,7 +140,7 @@ public virtual MoneroBlockHeader SetDifficulty(ulong? difficulty)
140140
141141 public virtual MoneroBlockHeader SetCumulativeDifficulty ( ulong ? cumulativeDifficulty )
142142 {
143- this . _cumulativeDifficulty = cumulativeDifficulty ;
143+ _cumulativeDifficulty = cumulativeDifficulty ;
144144 return this ;
145145 }
146146
@@ -151,7 +151,7 @@ public virtual MoneroBlockHeader SetCumulativeDifficulty(ulong? cumulativeDiffic
151151
152152 public virtual MoneroBlockHeader SetMajorVersion ( uint ? majorVersion )
153153 {
154- this . _majorVersion = majorVersion ;
154+ _majorVersion = majorVersion ;
155155 return this ;
156156 }
157157
@@ -162,7 +162,7 @@ public virtual MoneroBlockHeader SetMajorVersion(uint? majorVersion)
162162
163163 public virtual MoneroBlockHeader SetMinorVersion ( uint ? minorVersion )
164164 {
165- this . _minorVersion = minorVersion ;
165+ _minorVersion = minorVersion ;
166166 return this ;
167167 }
168168
@@ -173,7 +173,7 @@ public virtual MoneroBlockHeader SetMinorVersion(uint? minorVersion)
173173
174174 public virtual MoneroBlockHeader SetNonce ( ulong ? nonce )
175175 {
176- this . _nonce = nonce ;
176+ _nonce = nonce ;
177177 return this ;
178178 }
179179
@@ -184,7 +184,7 @@ public virtual MoneroBlockHeader SetNonce(ulong? nonce)
184184
185185 public virtual MoneroBlockHeader SetMinerTxHash ( string ? minerTxHash )
186186 {
187- this . _minerTxHash = minerTxHash ;
187+ _minerTxHash = minerTxHash ;
188188 return this ;
189189 }
190190
@@ -195,7 +195,7 @@ public virtual MoneroBlockHeader SetMinerTxHash(string? minerTxHash)
195195
196196 public virtual MoneroBlockHeader SetNumTxs ( uint ? numTxs )
197197 {
198- this . _numTxs = numTxs ;
198+ _numTxs = numTxs ;
199199 return this ;
200200 }
201201
@@ -206,7 +206,7 @@ public virtual MoneroBlockHeader SetNumTxs(uint? numTxs)
206206
207207 public virtual MoneroBlockHeader SetOrphanStatus ( bool ? orphanStatus )
208208 {
209- this . _orphanStatus = orphanStatus ;
209+ _orphanStatus = orphanStatus ;
210210 return this ;
211211 }
212212
@@ -217,7 +217,7 @@ public virtual MoneroBlockHeader SetOrphanStatus(bool? orphanStatus)
217217
218218 public virtual MoneroBlockHeader SetPrevHash ( string ? prevHash )
219219 {
220- this . _prevHash = prevHash ;
220+ _prevHash = prevHash ;
221221 return this ;
222222 }
223223
@@ -228,7 +228,7 @@ public virtual MoneroBlockHeader SetPrevHash(string? prevHash)
228228
229229 public virtual MoneroBlockHeader SetReward ( ulong ? reward )
230230 {
231- this . _reward = reward ;
231+ _reward = reward ;
232232 return this ;
233233 }
234234
@@ -239,38 +239,54 @@ public virtual MoneroBlockHeader SetReward(ulong? reward)
239239
240240 public virtual MoneroBlockHeader SetPowHash ( string ? powHash )
241241 {
242- this . _powHash = powHash ;
242+ _powHash = powHash ;
243243 return this ;
244244 }
245245
246246 public virtual MoneroBlockHeader Merge ( MoneroBlockHeader ? header )
247247 {
248- if ( header == null ) throw new ArgumentNullException ( nameof ( header ) , "Cannot merge null header into block header" ) ;
249- if ( this == header ) return this ;
250- this . SetHash ( GenUtils . Reconcile ( this . GetHash ( ) , header . GetHash ( ) ) ) ;
251- this . SetHeight ( GenUtils . Reconcile ( this . GetHeight ( ) , header . GetHeight ( ) , null , null , true ) ) ; // height can increase
252- this . SetTimestamp ( GenUtils . Reconcile ( this . GetTimestamp ( ) , header . GetTimestamp ( ) , null , null , true ) ) ; // block timestamp can increase
253- this . SetSize ( GenUtils . Reconcile ( this . GetSize ( ) , header . GetSize ( ) ) ) ;
254- this . SetWeight ( GenUtils . Reconcile ( this . GetWeight ( ) , header . GetWeight ( ) ) ) ;
255- this . SetDepth ( GenUtils . Reconcile ( this . GetDepth ( ) , header . GetDepth ( ) ) ) ;
256- this . SetDifficulty ( GenUtils . Reconcile ( this . GetDifficulty ( ) , header . GetDifficulty ( ) ) ) ;
257- this . SetCumulativeDifficulty ( GenUtils . Reconcile ( this . GetCumulativeDifficulty ( ) , header . GetCumulativeDifficulty ( ) ) ) ;
258- this . SetMajorVersion ( GenUtils . Reconcile ( this . GetMajorVersion ( ) , header . GetMajorVersion ( ) ) ) ;
259- this . SetMinorVersion ( GenUtils . Reconcile ( this . GetMinorVersion ( ) , header . GetMinorVersion ( ) ) ) ;
260- this . SetNonce ( GenUtils . Reconcile ( this . GetNonce ( ) , header . GetNonce ( ) ) ) ;
261- this . SetMinerTxHash ( GenUtils . Reconcile ( this . GetMinerTxHash ( ) , header . GetMinerTxHash ( ) ) ) ;
262- this . SetNumTxs ( GenUtils . Reconcile ( this . GetNumTxs ( ) , header . GetNumTxs ( ) ) ) ;
263- this . SetOrphanStatus ( GenUtils . Reconcile ( this . GetOrphanStatus ( ) , header . GetOrphanStatus ( ) ) ) ;
264- this . SetPrevHash ( GenUtils . Reconcile ( this . GetPrevHash ( ) , header . GetPrevHash ( ) ) ) ;
265- this . SetReward ( GenUtils . Reconcile ( this . GetReward ( ) , header . GetReward ( ) ) ) ;
266- this . SetPowHash ( GenUtils . Reconcile ( this . GetPowHash ( ) , header . GetPowHash ( ) ) ) ;
248+ if ( header == null )
249+ {
250+ throw new ArgumentNullException ( nameof ( header ) , "Cannot merge null header into block header" ) ;
251+ }
252+
253+ if ( this == header )
254+ {
255+ return this ;
256+ }
257+
258+ SetHash ( GenUtils . Reconcile ( GetHash ( ) , header . GetHash ( ) ) ) ;
259+ SetHeight ( GenUtils . Reconcile ( GetHeight ( ) , header . GetHeight ( ) , null , null , true ) ) ; // height can increase
260+ SetTimestamp ( GenUtils . Reconcile ( GetTimestamp ( ) , header . GetTimestamp ( ) , null , null , true ) ) ; // block timestamp can increase
261+ SetSize ( GenUtils . Reconcile ( GetSize ( ) , header . GetSize ( ) ) ) ;
262+ SetWeight ( GenUtils . Reconcile ( GetWeight ( ) , header . GetWeight ( ) ) ) ;
263+ SetDepth ( GenUtils . Reconcile ( GetDepth ( ) , header . GetDepth ( ) ) ) ;
264+ SetDifficulty ( GenUtils . Reconcile ( GetDifficulty ( ) , header . GetDifficulty ( ) ) ) ;
265+ SetCumulativeDifficulty ( GenUtils . Reconcile ( GetCumulativeDifficulty ( ) , header . GetCumulativeDifficulty ( ) ) ) ;
266+ SetMajorVersion ( GenUtils . Reconcile ( GetMajorVersion ( ) , header . GetMajorVersion ( ) ) ) ;
267+ SetMinorVersion ( GenUtils . Reconcile ( GetMinorVersion ( ) , header . GetMinorVersion ( ) ) ) ;
268+ SetNonce ( GenUtils . Reconcile ( GetNonce ( ) , header . GetNonce ( ) ) ) ;
269+ SetMinerTxHash ( GenUtils . Reconcile ( GetMinerTxHash ( ) , header . GetMinerTxHash ( ) ) ) ;
270+ SetNumTxs ( GenUtils . Reconcile ( GetNumTxs ( ) , header . GetNumTxs ( ) ) ) ;
271+ SetOrphanStatus ( GenUtils . Reconcile ( GetOrphanStatus ( ) , header . GetOrphanStatus ( ) ) ) ;
272+ SetPrevHash ( GenUtils . Reconcile ( GetPrevHash ( ) , header . GetPrevHash ( ) ) ) ;
273+ SetReward ( GenUtils . Reconcile ( GetReward ( ) , header . GetReward ( ) ) ) ;
274+ SetPowHash ( GenUtils . Reconcile ( GetPowHash ( ) , header . GetPowHash ( ) ) ) ;
267275 return this ;
268276 }
269277
270278 public virtual bool Equals ( MoneroBlockHeader ? other )
271279 {
272- if ( other == null ) return false ;
273- if ( other == this ) return true ;
280+ if ( other == null )
281+ {
282+ return false ;
283+ }
284+
285+ if ( other == this )
286+ {
287+ return true ;
288+ }
289+
274290 return _hash == other . _hash &&
275291 _height == other . _height &&
276292 _timestamp == other . _timestamp &&
0 commit comments