Update consensus, load pool block metadata from api
This commit is contained in:
parent
31ddcaa1bd
commit
a272187aa4
|
@ -1,6 +1,7 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"git.gammaspectra.live/P2Pool/consensus/v3/p2pool/sidechain"
|
||||
"git.gammaspectra.live/P2Pool/consensus/v3/types"
|
||||
)
|
||||
|
||||
|
@ -12,15 +13,17 @@ type P2PoolSideChainStateResult struct {
|
|||
}
|
||||
|
||||
type P2PoolBinaryBlockResult struct {
|
||||
Version int `json:"version"`
|
||||
Blob types.Bytes `json:"blob"`
|
||||
Error string `json:"error,omitempty"`
|
||||
Version int `json:"version"`
|
||||
Blob types.Bytes `json:"blob"`
|
||||
Metadata sidechain.PoolBlockReceptionMetadata `json:"metadata,omitempty"`
|
||||
Error string `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
type P2PoolSpecialBinaryBlockResult struct {
|
||||
Version int `json:"version"`
|
||||
Blob types.Bytes `json:"blob"`
|
||||
Error string `json:"error,omitempty"`
|
||||
Version int `json:"version"`
|
||||
Blob types.Bytes `json:"blob"`
|
||||
Metadata sidechain.PoolBlockReceptionMetadata `json:"metadata,omitempty"`
|
||||
Error string `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
type P2PoolSideChainStatusResult struct {
|
||||
|
|
|
@ -158,6 +158,8 @@ func (p *P2PoolApi) ByMainId(id types.Hash) *sidechain.PoolBlock {
|
|||
if err = b.UnmarshalBinary(p.Consensus(), p.derivationCache, result.Blob); err != nil || int(b.ShareVersion()) != result.Version {
|
||||
return nil
|
||||
}
|
||||
b.Metadata = result.Metadata
|
||||
|
||||
return b
|
||||
}
|
||||
}
|
||||
|
@ -182,6 +184,8 @@ func (p *P2PoolApi) ByMainIdWithHint(id, templateIdHint types.Hash) *sidechain.P
|
|||
if err = b.UnmarshalBinary(p.Consensus(), p.derivationCache, result.Blob); err != nil || int(b.ShareVersion()) != result.Version {
|
||||
return nil
|
||||
}
|
||||
b.Metadata = result.Metadata
|
||||
|
||||
return b
|
||||
}
|
||||
}
|
||||
|
@ -245,6 +249,8 @@ func (p *P2PoolApi) ByTemplateId(id types.Hash) *sidechain.PoolBlock {
|
|||
if err = b.UnmarshalBinary(p.Consensus(), p.derivationCache, r.Blob); err != nil || int(b.ShareVersion()) != r.Version {
|
||||
continue
|
||||
}
|
||||
|
||||
b.Metadata = r.Metadata
|
||||
return b
|
||||
}
|
||||
return nil
|
||||
|
@ -256,6 +262,8 @@ func (p *P2PoolApi) ByTemplateId(id types.Hash) *sidechain.PoolBlock {
|
|||
if err = b.UnmarshalBinary(p.Consensus(), p.derivationCache, result.Blob); err != nil {
|
||||
return nil
|
||||
}
|
||||
b.Metadata = result.Metadata
|
||||
|
||||
return b
|
||||
}
|
||||
}
|
||||
|
@ -319,6 +327,8 @@ func (p *P2PoolApi) BySideHeight(height uint64) sidechain.UniquePoolBlockSlice {
|
|||
if err = b.UnmarshalBinary(p.Consensus(), p.derivationCache, r.Blob); err != nil {
|
||||
return nil
|
||||
}
|
||||
b.Metadata = r.Metadata
|
||||
|
||||
results = append(results, b)
|
||||
}
|
||||
return results
|
||||
|
@ -335,6 +345,8 @@ func (p *P2PoolApi) BySideHeight(height uint64) sidechain.UniquePoolBlockSlice {
|
|||
if err = b.UnmarshalBinary(p.Consensus(), p.derivationCache, r.Blob); err != nil {
|
||||
return nil
|
||||
}
|
||||
b.Metadata = r.Metadata
|
||||
|
||||
results = append(results, b)
|
||||
}
|
||||
return results
|
||||
|
@ -386,6 +398,8 @@ func (p *P2PoolApi) ByMainHeight(height uint64) sidechain.UniquePoolBlockSlice {
|
|||
if err = b.UnmarshalBinary(p.Consensus(), p.derivationCache, r.Blob); err != nil {
|
||||
return nil
|
||||
}
|
||||
b.Metadata = r.Metadata
|
||||
|
||||
results = append(results, b)
|
||||
}
|
||||
return results
|
||||
|
@ -570,6 +584,7 @@ func (p *P2PoolApi) StateFromTemplateId(id types.Hash) (chain, uncles sidechain.
|
|||
if err = b.UnmarshalBinary(p.Consensus(), p.derivationCache, r.Blob); err != nil {
|
||||
return nil, nil
|
||||
}
|
||||
b.Metadata = r.Metadata
|
||||
chain = append(chain, b)
|
||||
}
|
||||
|
||||
|
@ -578,6 +593,7 @@ func (p *P2PoolApi) StateFromTemplateId(id types.Hash) (chain, uncles sidechain.
|
|||
if err = b.UnmarshalBinary(p.Consensus(), p.derivationCache, r.Blob); err != nil {
|
||||
return nil, nil
|
||||
}
|
||||
b.Metadata = r.Metadata
|
||||
uncles = append(uncles, b)
|
||||
}
|
||||
|
||||
|
@ -609,6 +625,7 @@ func (p *P2PoolApi) WindowFromTemplateId(id types.Hash) (chain, uncles sidechain
|
|||
if err = b.UnmarshalBinary(p.Consensus(), p.derivationCache, r.Blob); err != nil {
|
||||
return nil, nil
|
||||
}
|
||||
b.Metadata = r.Metadata
|
||||
chain = append(chain, b)
|
||||
}
|
||||
|
||||
|
@ -617,6 +634,7 @@ func (p *P2PoolApi) WindowFromTemplateId(id types.Hash) (chain, uncles sidechain
|
|||
if err = b.UnmarshalBinary(p.Consensus(), p.derivationCache, r.Blob); err != nil {
|
||||
return nil, nil
|
||||
}
|
||||
b.Metadata = r.Metadata
|
||||
uncles = append(uncles, b)
|
||||
}
|
||||
|
||||
|
@ -648,6 +666,7 @@ func (p *P2PoolApi) StateFromTip() (chain, uncles sidechain.UniquePoolBlockSlice
|
|||
if err = b.UnmarshalBinary(p.Consensus(), p.derivationCache, r.Blob); err != nil {
|
||||
return nil, nil
|
||||
}
|
||||
b.Metadata = r.Metadata
|
||||
chain = append(chain, b)
|
||||
}
|
||||
|
||||
|
@ -656,6 +675,7 @@ func (p *P2PoolApi) StateFromTip() (chain, uncles sidechain.UniquePoolBlockSlice
|
|||
if err = b.UnmarshalBinary(p.Consensus(), p.derivationCache, r.Blob); err != nil {
|
||||
return nil, nil
|
||||
}
|
||||
b.Metadata = r.Metadata
|
||||
uncles = append(uncles, b)
|
||||
}
|
||||
|
||||
|
@ -686,6 +706,7 @@ func (p *P2PoolApi) Tip() *sidechain.PoolBlock {
|
|||
if err = b.UnmarshalBinary(p.Consensus(), p.derivationCache, result.Blob); err != nil {
|
||||
return nil
|
||||
}
|
||||
b.Metadata = result.Metadata
|
||||
return b
|
||||
}
|
||||
}
|
||||
|
|
2
go.mod
2
go.mod
|
@ -3,7 +3,7 @@ module git.gammaspectra.live/P2Pool/observer-cmd-utils
|
|||
go 1.22
|
||||
|
||||
require (
|
||||
git.gammaspectra.live/P2Pool/consensus/v3 v3.6.1
|
||||
git.gammaspectra.live/P2Pool/consensus/v3 v3.6.4
|
||||
git.gammaspectra.live/P2Pool/sha3 v0.17.0
|
||||
github.com/goccy/go-json v0.10.2
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7
|
||||
|
|
6
go.sum
6
go.sum
|
@ -1,7 +1,5 @@
|
|||
git.gammaspectra.live/P2Pool/consensus/v3 v3.6.0 h1:ICTC2jzsnfoXbFlpFK0U3pEIX04GL4ncmQ6MW4Xsz7A=
|
||||
git.gammaspectra.live/P2Pool/consensus/v3 v3.6.0/go.mod h1:3mjTaEx2Hm9VUs0rZIjCAFV6fToNxnVDj616NEc9Y0I=
|
||||
git.gammaspectra.live/P2Pool/consensus/v3 v3.6.1 h1:2ytho+vzgm8R0Q6K65Ps5N67REONgABYouQ56ETwIL8=
|
||||
git.gammaspectra.live/P2Pool/consensus/v3 v3.6.1/go.mod h1:3mjTaEx2Hm9VUs0rZIjCAFV6fToNxnVDj616NEc9Y0I=
|
||||
git.gammaspectra.live/P2Pool/consensus/v3 v3.6.4 h1:z/+WQrPQK5RDdWwm2od9Ltpk9TFAyNhR7j1cTAFfe8Y=
|
||||
git.gammaspectra.live/P2Pool/consensus/v3 v3.6.4/go.mod h1:3mjTaEx2Hm9VUs0rZIjCAFV6fToNxnVDj616NEc9Y0I=
|
||||
git.gammaspectra.live/P2Pool/edwards25519 v0.0.0-20240405085108-e2f706cb5c00 h1:mDQY337iKB+kle5RYWL5CoAz+3DmnkAh/B2XD8B+PFk=
|
||||
git.gammaspectra.live/P2Pool/edwards25519 v0.0.0-20240405085108-e2f706cb5c00/go.mod h1:FZsrMWGucMP3SZamzrd7m562geIs5zp1O/9MGoiAKH0=
|
||||
git.gammaspectra.live/P2Pool/go-randomx/v2 v2.1.0 h1:L1fV2XBYFmpFU+JKP/7fsgDm2Lfh9yFlS+800v+3OsM=
|
||||
|
|
Loading…
Reference in a new issue