-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6933 from filecoin-project/jen/bp-to-release
Fixes in master -> release
- Loading branch information
Showing
27 changed files
with
735 additions
and
222 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package api | ||
|
||
import ( | ||
"encoding/json" | ||
) | ||
|
||
// MinerSubsystem represents a miner subsystem. Int and string values are not | ||
// guaranteed to be stable over time is not | ||
// guaranteed to be stable over time. | ||
type MinerSubsystem int | ||
|
||
const ( | ||
// SubsystemUnknown is a placeholder for the zero value. It should never | ||
// be used. | ||
SubsystemUnknown MinerSubsystem = iota | ||
// SubsystemMarkets signifies the storage and retrieval | ||
// deal-making subsystem. | ||
SubsystemMarkets | ||
// SubsystemMining signifies the mining subsystem. | ||
SubsystemMining | ||
// SubsystemSealing signifies the sealing subsystem. | ||
SubsystemSealing | ||
// SubsystemSectorStorage signifies the sector storage subsystem. | ||
SubsystemSectorStorage | ||
) | ||
|
||
var MinerSubsystemToString = map[MinerSubsystem]string{ | ||
SubsystemUnknown: "Unknown", | ||
SubsystemMarkets: "Markets", | ||
SubsystemMining: "Mining", | ||
SubsystemSealing: "Sealing", | ||
SubsystemSectorStorage: "SectorStorage", | ||
} | ||
|
||
var MinerSubsystemToID = map[string]MinerSubsystem{ | ||
"Unknown": SubsystemUnknown, | ||
"Markets": SubsystemMarkets, | ||
"Mining": SubsystemMining, | ||
"Sealing": SubsystemSealing, | ||
"SectorStorage": SubsystemSectorStorage, | ||
} | ||
|
||
func (ms MinerSubsystem) MarshalJSON() ([]byte, error) { | ||
return json.Marshal(MinerSubsystemToString[ms]) | ||
} | ||
|
||
func (ms *MinerSubsystem) UnmarshalJSON(b []byte) error { | ||
var j string | ||
err := json.Unmarshal(b, &j) | ||
if err != nil { | ||
return err | ||
} | ||
s, ok := MinerSubsystemToID[j] | ||
if !ok { | ||
*ms = SubsystemUnknown | ||
} else { | ||
*ms = s | ||
} | ||
return nil | ||
} | ||
|
||
type MinerSubsystems []MinerSubsystem | ||
|
||
func (ms MinerSubsystems) Has(entry MinerSubsystem) bool { | ||
for _, v := range ms { | ||
if v == entry { | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
|
||
func (ms MinerSubsystem) String() string { | ||
s, ok := MinerSubsystemToString[ms] | ||
if !ok { | ||
return MinerSubsystemToString[SubsystemUnknown] | ||
} | ||
return s | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains 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
This file contains 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
Oops, something went wrong.