pull more things apart

This commit is contained in:
whyrusleeping
2019-07-26 13:49:30 +02:00
committed by Łukasz Magiera
parent 6ca033f313
commit 78da356752
22 changed files with 415 additions and 382 deletions
+2 -1
View File
@@ -24,6 +24,7 @@ import (
"github.com/filecoin-project/go-lotus/api"
"github.com/filecoin-project/go-lotus/chain"
"github.com/filecoin-project/go-lotus/chain/store"
"github.com/filecoin-project/go-lotus/chain/types"
"github.com/filecoin-project/go-lotus/node/config"
"github.com/filecoin-project/go-lotus/node/hello"
@@ -183,7 +184,7 @@ func Online() Option {
Override(HandleIncomingMessagesKey, modules.HandleIncomingMessages),
Override(new(*chain.ChainStore), modules.ChainStore),
Override(new(*store.ChainStore), modules.ChainStore),
Override(new(blockstore.GCLocker), blockstore.NewGCLocker),
Override(new(blockstore.GCBlockstore), blockstore.NewGCBlockstore),
+3 -2
View File
@@ -12,6 +12,7 @@ import (
"github.com/libp2p/go-libp2p-core/peer"
"github.com/filecoin-project/go-lotus/chain"
"github.com/filecoin-project/go-lotus/chain/store"
"github.com/filecoin-project/go-lotus/lib/cborrpc"
)
@@ -32,11 +33,11 @@ type Message struct {
type Service struct {
newStream chain.NewStreamFunc
cs *chain.ChainStore
cs *store.ChainStore
syncer *chain.Syncer
}
func NewHelloService(h host.Host, cs *chain.ChainStore, syncer *chain.Syncer) *Service {
func NewHelloService(h host.Host, cs *store.ChainStore, syncer *chain.Syncer) *Service {
return &Service{
newStream: h.NewStream,
+7 -5
View File
@@ -2,11 +2,13 @@ package impl
import (
"context"
"golang.org/x/xerrors"
"github.com/filecoin-project/go-lotus/api"
"github.com/filecoin-project/go-lotus/chain"
"github.com/filecoin-project/go-lotus/chain/address"
"github.com/filecoin-project/go-lotus/chain/store"
"github.com/filecoin-project/go-lotus/chain/types"
"github.com/filecoin-project/go-lotus/miner"
"github.com/filecoin-project/go-lotus/node/client"
@@ -23,7 +25,7 @@ type FullNodeAPI struct {
CommonAPI
Chain *chain.ChainStore
Chain *store.ChainStore
PubSub *pubsub.PubSub
Mpool *chain.MessagePool
Wallet *chain.Wallet
@@ -43,11 +45,11 @@ func (a *FullNodeAPI) ChainSubmitBlock(ctx context.Context, blk *chain.BlockMsg)
return a.PubSub.Publish("/fil/blocks", b)
}
func (a *FullNodeAPI) ChainHead(context.Context) (*chain.TipSet, error) {
func (a *FullNodeAPI) ChainHead(context.Context) (*types.TipSet, error) {
return a.Chain.GetHeaviestTipSet(), nil
}
func (a *FullNodeAPI) ChainGetRandomness(ctx context.Context, pts *chain.TipSet) ([]byte, error) {
func (a *FullNodeAPI) ChainGetRandomness(ctx context.Context, pts *types.TipSet) ([]byte, error) {
// TODO: this needs to look back in the chain for the right random beacon value
return []byte("foo bar random"), nil
}
@@ -69,7 +71,7 @@ func (a *FullNodeAPI) ChainGetBlockMessages(ctx context.Context, msg cid.Cid) ([
return a.Chain.MessagesForBlock(b)
}
func (a *FullNodeAPI) MpoolPending(ctx context.Context, ts *chain.TipSet) ([]*types.SignedMessage, error) {
func (a *FullNodeAPI) MpoolPending(ctx context.Context, ts *types.TipSet) ([]*types.SignedMessage, error) {
// TODO: need to make sure we don't return messages that were already included in the referenced chain
// also need to accept ts == nil just fine, assume nil == chain.Head()
return a.Mpool.Pending(), nil
@@ -97,7 +99,7 @@ func (a *FullNodeAPI) MinerStart(ctx context.Context, addr address.Address) erro
return nil
}
func (a *FullNodeAPI) MinerCreateBlock(ctx context.Context, addr address.Address, parents *chain.TipSet, tickets []types.Ticket, proof types.ElectionProof, msgs []*types.SignedMessage) (*chain.BlockMsg, error) {
func (a *FullNodeAPI) MinerCreateBlock(ctx context.Context, addr address.Address, parents *types.TipSet, tickets []types.Ticket, proof types.ElectionProof, msgs []*types.SignedMessage) (*chain.BlockMsg, error) {
fblk, err := chain.MinerCreateBlock(a.Chain, addr, parents, tickets, proof, msgs)
if err != nil {
return nil, err
+4 -4
View File
@@ -30,7 +30,7 @@ import (
"golang.org/x/xerrors"
"github.com/filecoin-project/go-lotus/api"
"github.com/filecoin-project/go-lotus/chain"
"github.com/filecoin-project/go-lotus/chain/store"
"github.com/filecoin-project/go-lotus/chain/types"
"github.com/filecoin-project/go-lotus/node/modules/helpers"
"github.com/filecoin-project/go-lotus/node/repo"
@@ -58,7 +58,7 @@ func Bitswap(mctx helpers.MetricsCtx, lc fx.Lifecycle, host host.Host, rt routin
return exch
}
func SetGenesis(cs *chain.ChainStore, g Genesis) error {
func SetGenesis(cs *store.ChainStore, g Genesis) error {
_, err := cs.GetGenesis()
if err == nil {
return nil // already set, noop
@@ -179,8 +179,8 @@ func ClientDAG(lc fx.Lifecycle, fstore *filestore.Filestore) ipld.DAGService {
return dag
}
func ChainStore(lc fx.Lifecycle, bs blockstore.Blockstore, ds datastore.Batching) *chain.ChainStore {
chain := chain.NewChainStore(bs, ds)
func ChainStore(lc fx.Lifecycle, bs blockstore.Blockstore, ds datastore.Batching) *store.ChainStore {
chain := store.NewChainStore(bs, ds)
lc.Append(fx.Hook{
OnStart: func(ctx context.Context) error {