placeholder tipset.Weight implementation

This commit is contained in:
Łukasz Magiera 2019-08-22 01:24:59 +02:00
parent 28409a60b1
commit 834837690b
2 changed files with 8 additions and 3 deletions

View File

@ -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 {

View File

@ -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
}
}