Stricter compliance to old API

This commit is contained in:
DataHoarder 2022-10-08 22:39:40 +02:00
parent 2cdc16a9f8
commit 4f1c4acbe5
Signed by: DataHoarder
SSH key fingerprint: SHA256:OLTRf6Fl87G52SiR7sWLGNzlJt4WOX+tfI2yxo0z7xk
5 changed files with 13 additions and 12 deletions

View file

@ -283,7 +283,7 @@ func main() {
Id: block.Id,
Height: block.Height,
Timestamp: block.Timestamp,
Weight: block.Difficulty,
Weight: block.Difficulty.Lo,
}
for u := range api.GetDatabase().GetUnclesByParentId(block.Id) {
@ -291,9 +291,9 @@ func main() {
s.Uncles = append(s.Uncles, sharesInWindowResultUncle{
Id: u.Block.Id,
Height: u.Block.Height,
Weight: types.Difficulty{Uint128: uncleWeight},
Weight: uncleWeight.Lo,
})
s.Weight.Uint128 = s.Weight.Add(uncleWeight)
s.Weight += uncleWeight.Lo
}
result = append(result, s)
@ -308,7 +308,7 @@ func main() {
Id: uncle.Block.Id,
Height: uncle.Block.Height,
Timestamp: uncle.Block.Timestamp,
Weight: types.Difficulty{Uint128: uncle.Block.Difficulty.Mul64(100 - p2pool.UnclePenalty).Div64(100)},
Weight: uncle.Block.Difficulty.Mul64(100 - p2pool.UnclePenalty).Div64(100).Lo,
}
result = append(result, s)
}

View file

@ -66,6 +66,7 @@ func MapJSONBlock(api *api.Api, block database.BlockInterface, extraUncleData, e
}
weight := b.Difficulty
b.Uncles = make([]any, 0)
if uncle, ok := block.(*database.UncleBlock); ok {
b.Parent = &database.JSONBlockParent{

View file

@ -60,7 +60,7 @@ type sharesInWindowResult struct {
Id types.Hash `json:"id"`
Height uint64 `json:"height"`
Timestamp uint64 `json:"timestamp"`
Weight types.Difficulty `json:"weight"`
Weight uint64 `json:"weight"`
Uncles []sharesInWindowResultUncle `json:"uncles,omitempty"`
}
@ -70,7 +70,7 @@ type sharesInWindowResultParent struct {
}
type sharesInWindowResultUncle struct {
Id types.Hash `json:"id"`
Height uint64 `json:"height"`
Weight types.Difficulty `json:"weight"`
Id types.Hash `json:"id"`
Height uint64 `json:"height"`
Weight uint64 `json:"weight"`
}

View file

@ -96,12 +96,12 @@ type Block struct {
//Lock extra JSON field, do not use
Lock sync.Mutex `json:"-"`
//Weight extra JSON field, do not use
Weight uint64 `json:"weight"`
//Parent extra JSON field, do not use
Parent *JSONBlockParent `json:"parent,omitempty"`
//Uncles extra JSON field, do not use
Uncles []any `json:"uncles,omitempty"`
Uncles []any `json:"uncles"`
//Weight extra JSON field, do not use
Weight uint64 `json:"weight"`
//Orphan extra JSON field, do not use
Orphan bool `json:"orphan,omitempty"`

View file

@ -730,7 +730,7 @@ type Payout struct {
Height uint64 `json:"height"`
} `json:"main"`
Timestamp uint64 `json:"timestamp"`
Uncle bool `json:"uncle"`
Uncle bool `json:"uncle,omitempty"`
Coinbase struct {
Id types.Hash `json:"id"`
Reward uint64 `json:"reward"`