2020-06-30 13:18:01 +00:00
|
|
|
package build
|
|
|
|
|
|
|
|
import (
|
2021-04-09 06:58:22 +00:00
|
|
|
"github.com/ipfs/go-cid"
|
2022-08-25 18:20:41 +00:00
|
|
|
"github.com/libp2p/go-libp2p/core/protocol"
|
2020-06-30 13:18:01 +00:00
|
|
|
|
2022-06-14 15:00:51 +00:00
|
|
|
"github.com/filecoin-project/go-address"
|
|
|
|
|
2020-06-30 13:18:01 +00:00
|
|
|
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Core network constants
|
|
|
|
|
|
|
|
func BlocksTopic(netName dtypes.NetworkName) string { return "/fil/blocks/" + string(netName) }
|
|
|
|
func MessagesTopic(netName dtypes.NetworkName) string { return "/fil/msgs/" + string(netName) }
|
2022-02-04 08:15:01 +00:00
|
|
|
func IndexerIngestTopic(netName dtypes.NetworkName) string {
|
2022-02-11 19:36:36 +00:00
|
|
|
|
|
|
|
nn := string(netName)
|
|
|
|
// The network name testnetnet is here for historical reasons.
|
|
|
|
// Going forward we aim to use the name `mainnet` where possible.
|
|
|
|
if nn == "testnetnet" {
|
|
|
|
nn = "mainnet"
|
|
|
|
}
|
|
|
|
|
|
|
|
return "/indexer/ingest/" + nn
|
2022-02-04 08:15:01 +00:00
|
|
|
}
|
2020-06-30 13:18:01 +00:00
|
|
|
func DhtProtocolName(netName dtypes.NetworkName) protocol.ID {
|
|
|
|
return protocol.ID("/fil/kad/" + string(netName))
|
|
|
|
}
|
2020-09-10 18:53:10 +00:00
|
|
|
|
2020-09-25 19:45:27 +00:00
|
|
|
func SetAddressNetwork(n address.Network) {
|
|
|
|
address.CurrentNetwork = n
|
|
|
|
}
|
2020-11-17 06:34:06 +00:00
|
|
|
|
|
|
|
func MustParseAddress(addr string) address.Address {
|
|
|
|
ret, err := address.NewFromString(addr)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret
|
|
|
|
}
|
2021-04-09 06:58:22 +00:00
|
|
|
|
|
|
|
func MustParseCid(c string) cid.Cid {
|
|
|
|
ret, err := cid.Decode(c)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret
|
|
|
|
}
|