This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// UpgradeHandler specifies the type of function that is called when an upgrade | |
// is applied. | |
// | |
// `fromVM` is a VersionMap of moduleName to fromVersion (unit64), where | |
// fromVersion denotes the version from which we should migrate the module, the | |
// target version being the module's latest version in the return VersionMap, | |
// let's call it `toVM`. | |
// | |
// `fromVM` is retrieved from x/upgrade's store, whereas `toVM` is chosen | |
// arbitrarily by the app developer (and persisted to x/upgrade's store right |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func NewSimApp(...) *SimApp { | |
... | |
// register the proposal types | |
govRouter := govtypes.NewRouter() | |
govRouter.AddRoute(govtypes.RouterKey, govtypes.ProposalHandler). | |
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)) | |
govKeeper := govkeeper.NewKeeper( | |
appCodec, keys[govtypes.StoreKey], app.GetSubspace(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper, | |
&stakingKeeper, govRouter, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// EndBlocker called every block, process inflation, update validator set. | |
func EndBlocker(ctx sdk.Context, keeper keeper.Keeper) { | |
keeper.IterateActiveProposalsQueue(ctx, ctx.BlockHeader().Time, func(proposal types.Proposal) bool { | |
passes, burnDeposits, tallyResults := keeper.Tally(ctx, proposal) | |
... | |
if passes { | |
handler := keeper.Router().GetRoute(proposal.ProposalRoute()) | |
cacheCtx, writeCache := ctx.CacheContext() | |
err := handler(cacheCtx, proposal.GetContent()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SoftwareUpgradeProposal is a gov Content type for initiating a software | |
// upgrade. | |
message SoftwareUpgradeProposal { | |
string title = 1; | |
string description = 2; | |
Plan plan = 3 [(gogoproto.nullable) = false]; | |
} | |
// Plan specifies information about a planned upgrade and when it should occur. | |
message Plan { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
. # $DAEMON_HOME | |
βββ config | |
βββ cosmovisor | |
β βββ current # symbolic link | |
β βββ genesis | |
β β βββ bin | |
β β βββ simappd # $DAEMON_NAME | |
β βββ upgrades | |
β βββ v2.0.0 # upgrade name | |
β βββ bin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func Build() (host1 *link.Host, host2 *link.Host, host3 *link.Host, | |
swch1 *link.Switch, swch2 *link.Switch) { | |
// setup node | |
// setup interface | |
... | |
// setup link | |
link1 := link.NewLink(1) | |
attachLink(intf1, link1) | |
attachLink(sp11, link1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func Build() (host1 *link.Host, host2 *link.Host, host3 *link.Host, | |
swch1 *link.Switch, swch2 *link.Switch) { | |
// setup node | |
... | |
// setup interface | |
intf1 := link.NewInterface(40001, link.AddrFromStr("11-11-11-11-11-11"), host1) | |
attachInterface(host1, intf1) | |
intf2 := link.NewInterface(40002, link.AddrFromStr("22-22-22-22-22-22"), host2) | |
attachInterface(host2, intf2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func Build() (host1 *link.Host, host2 *link.Host, host3 *link.Host, | |
swch1 *link.Switch, swch2 *link.Switch) { | |
// setup node | |
host1 = link.NewHost() | |
host2 = link.NewHost() | |
host3 = link.NewHost() | |
swch1 = link.NewSwitch() | |
swch2 = link.NewSwitch() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Forward receives id of port it receives frame, address of sender | |
// and frame to send to receiver. Based on id and address it determines whether to | |
// broadcast frame or forward it to others, otherwise just discard frame. | |
func (s *Switch) Forward(incoming Id, frame na.Frame) error { | |
s.Table.Update(incoming, frame.Src) | |
frm, err := s.frmEnc.Encode(frame) | |
if err != nil { | |
return err | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Port can transmit data and can be point of link. But it has no hardware | |
// address. Before using Port, it must register its own Id | |
type Port interface { | |
Transmitter | |
EndPoint | |
Register(id Id) | |
Registered() bool | |
} |