Get network name from genesis

This commit is contained in:
Łukasz Magiera
2020-04-01 01:15:49 +02:00
parent ea135991e3
commit 13f2c21e1d
16 changed files with 99 additions and 43 deletions
+5
View File
@@ -16,6 +16,7 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-amt-ipld/v2"
"github.com/filecoin-project/lotus/node/modules/dtypes"
"github.com/filecoin-project/specs-actors/actors/abi"
"github.com/filecoin-project/specs-actors/actors/abi/big"
"github.com/filecoin-project/specs-actors/actors/builtin"
@@ -47,6 +48,10 @@ type StateAPI struct {
Chain *store.ChainStore
}
func (a *StateAPI) StateNetworkName(ctx context.Context) (dtypes.NetworkName, error) {
return stmgr.GetNetworkName(ctx, a.StateManager, a.Chain.GetHeaviestTipSet().ParentState())
}
func (a *StateAPI) StateMinerSectors(ctx context.Context, addr address.Address, tsk types.TipSetKey) ([]*api.ChainSectorInfo, error) {
ts, err := a.Chain.GetTipSetFromKey(tsk)
if err != nil {
+10 -8
View File
@@ -3,22 +3,24 @@ package full
import (
"context"
cid "github.com/ipfs/go-cid"
pubsub "github.com/libp2p/go-libp2p-pubsub"
"go.uber.org/fx"
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/build"
"github.com/filecoin-project/lotus/chain"
"github.com/filecoin-project/lotus/chain/types"
cid "github.com/ipfs/go-cid"
pubsub "github.com/libp2p/go-libp2p-pubsub"
"go.uber.org/fx"
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/node/modules/dtypes"
)
type SyncAPI struct {
fx.In
Syncer *chain.Syncer
PubSub *pubsub.PubSub
Syncer *chain.Syncer
PubSub *pubsub.PubSub
NetName dtypes.NetworkName
}
func (a *SyncAPI) SyncState(ctx context.Context) (*api.SyncState, error) {
@@ -77,7 +79,7 @@ func (a *SyncAPI) SyncSubmitBlock(ctx context.Context, blk *types.BlockMsg) erro
}
// TODO: anything else to do here?
return a.PubSub.Publish(build.BlocksTopic, b)
return a.PubSub.Publish(build.BlocksTopic(a.NetName), b)
}
func (a *SyncAPI) SyncIncomingBlocks(ctx context.Context) (<-chan *types.BlockHeader, error) {