placeholder tipset.Weight implementation
This commit is contained in:
parent
28409a60b1
commit
834837690b
@ -6,8 +6,11 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
logging "github.com/ipfs/go-log"
|
||||
)
|
||||
|
||||
var log = logging.Logger("types")
|
||||
|
||||
type TipSet struct {
|
||||
cids []cid.Cid
|
||||
blks []*BlockHeader
|
||||
@ -65,8 +68,10 @@ func (ts *TipSet) Height() uint64 {
|
||||
return ts.height
|
||||
}
|
||||
|
||||
func (ts *TipSet) Weight() uint64 {
|
||||
panic("if tipsets are going to have weight on them, we need to wire that through")
|
||||
func (ts *TipSet) Weight() BigInt {
|
||||
// TODO: implement correctly
|
||||
log.Warn("Called TipSet.Weight: TODO: correct implementation")
|
||||
return BigAdd(ts.blks[0].ParentWeight, NewInt(1))
|
||||
}
|
||||
|
||||
func (ts *TipSet) Parents() []cid.Cid {
|
||||
|
@ -182,7 +182,7 @@ func (m *Miner) GetBestMiningCandidate() (*MiningBase, error) {
|
||||
return m.lastWork, nil
|
||||
}
|
||||
|
||||
if bts.Weight() <= m.lastWork.ts.Weight() {
|
||||
if types.BigCmp(bts.Weight(), m.lastWork.ts.Weight()) <= 0 {
|
||||
return m.lastWork, nil
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user