func NewShardManager(shardID uint64, init ShardChainInitializationParameters, beaconClient pb.BlockchainRPCClient, hn *p2p.HostNode) (*ShardManager, error) {

	genesisBlock := primitives.GetGenesisBlockForShard(shardID)

	stateDB := csmt.NewInMemoryTreeDB()
	shardInfo := state.ShardInfo{
		CurrentCode: transfer.Code, // TODO: this should be loaded dynamically instead of directly from the filesystem
		ShardID:     uint32(shardID),
	}

	sm := &ShardManager{
		ShardID:                  shardID,
		Chain:                    NewShardChain(init.RootSlot, &genesisBlock),
		Index:                    index.NewShardBlockIndex(genesisBlock),
		InitializationParameters: init,
		BeaconClient:             beaconClient,
		shardInfo:                shardInfo,
		stateManager:             state.NewShardStateManager(stateDB, init.RootSlot, init.RootBlockHash, shardInfo),
		notifees:                 []ShardChainActionNotifee{},
		BlockDB:                  db.NewMemoryBlockDB(),
	}

	// GlobalVis.addShard(sm)

	syncManager, err := NewShardSyncManager(hn, sm, shardID)
	if err != nil {
		return nil, err
	}

	sm.SyncManager = syncManager

	sm.ListenForNewCrosslinks()

	return sm, nil
}
// NewShardManager initializes a new shard manager responsible for keeping track of a shard chain.
NewShardManager initializes a new shard manager responsible for keeping track of a shard chain.
// NewShardManager initializes a new shard manager responsible for keeping track of a shard chain .
func NewShardManager(shardID uint64, init ShardChainInitializationParameters, beaconClient pb.BlockchainRPCClient, hn *p2p.HostNode) (*ShardManager, error) {
	genesisBlock := primitives.GetGenesisBlockForShard(shardID)
	stateDB := csmt.NewInMemoryTreeDB()
	shardInfo := state.ShardInfo{
		CurrentCode: transfer.Code, 
		ShardID:     uint32(shardID),
	}
	sm := &ShardManager{
		ShardID:                  shardID,
		Chain:                    NewShardChain(init.RootSlot, &genesisBlock),
		Index:                    index.NewShardBlockIndex(genesisBlock),
		InitializationParameters: init,
		BeaconClient:             beaconClient,
		shardInfo:                shardInfo,
		stateManager:             state.NewShardStateManager(stateDB, init.RootSlot, init.RootBlockHash, shardInfo),
		notifees:                 []ShardChainActionNotifee{},
		BlockDB:                  db.NewMemoryBlockDB(),
	}
	syncManager, err := NewShardSyncManager(hn, sm, shardID)
	if err != nil {
		return nil, err
	}
	sm.SyncManager = syncManager
	sm.ListenForNewCrosslinks()
	return sm, nil
}
func NewShardManager ( shardID uint64 , init ShardChainInitializationParameters , beaconClient pb . BlockchainRPCClient , hn * p2p . HostNode ) ( * ShardManager , error ) { genesisBlock := primitives . GetGenesisBlockForShard ( shardID ) stateDB := csmt . NewInMemoryTreeDB ( ) shardInfo := state . ShardInfo { CurrentCode : transfer . Code , ShardID : uint32 ( shardID ) , } sm := & ShardManager { ShardID : shardID , Chain : NewShardChain ( init . RootSlot , & genesisBlock ) , Index : index . NewShardBlockIndex ( genesisBlock ) , InitializationParameters : init , BeaconClient : beaconClient , shardInfo : shardInfo , stateManager : state . NewShardStateManager ( stateDB , init . RootSlot , init . RootBlockHash , shardInfo ) , notifees : [ ] ShardChainActionNotifee { } , BlockDB : db . NewMemoryBlockDB ( ) , } syncManager , err := NewShardSyncManager ( hn , sm , shardID ) if err != nil { return nil , err } sm . SyncManager = syncManager sm . ListenForNewCrosslinks ( ) return sm , nil }
NewShardManager initializes a new shard manager responsible for keeping track of a shard chain.
NewShardManager initializes a new shard manager responsible for keeping track of a shard chain .
// TODO: this should be loaded dynamically instead of directly from the filesystem // GlobalVis.addShard(sm)