-
-
Notifications
You must be signed in to change notification settings - Fork 21
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 #63 from KenshiTech/v0.11.8
v0.11.8
- Loading branch information
Showing
21 changed files
with
386 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,4 @@ docker/pgadmin | |
.clinic | ||
node_trace.* | ||
src/bin | ||
conf.*.private |
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
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,60 @@ | ||
/* | ||
Copyright © 2024 NAME HERE <EMAIL ADDRESS> | ||
*/ | ||
package cmd | ||
|
||
import ( | ||
"github.com/KenshiTech/unchained/bls" | ||
"github.com/KenshiTech/unchained/config" | ||
"github.com/KenshiTech/unchained/constants" | ||
"github.com/KenshiTech/unchained/log" | ||
"github.com/KenshiTech/unchained/net/client" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
// consumerCmd represents the consumer command | ||
var consumerCmd = &cobra.Command{ | ||
Use: "consumer", | ||
Short: "Run the Unchained client in consumer mode", | ||
Long: `Run the Unchained client in consumer mode`, | ||
|
||
PreRun: func(cmd *cobra.Command, args []string) { | ||
config.Config.BindPFlag("broker.uri", cmd.Flags().Lookup("broker")) | ||
}, | ||
|
||
Run: func(cmd *cobra.Command, args []string) { | ||
|
||
log.Logger. | ||
With("Version", constants.Version). | ||
With("Protocol", constants.ProtocolVersion). | ||
Info("Running Unchained") | ||
|
||
config.LoadConfig(configPath, secretsPath) | ||
bls.InitClientIdentity() | ||
client.StartClient() | ||
client.StartConsumer() | ||
client.ClientBlock() | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(consumerCmd) | ||
|
||
// Here you will define your flags and configuration settings. | ||
|
||
// Cobra supports Persistent Flags which will work for this command | ||
// and all subcommands, e.g.: | ||
// consumerCmd.PersistentFlags().String("foo", "", "A help for foo") | ||
|
||
// Cobra supports local flags which will only run when this command | ||
// is called directly, e.g.: | ||
// consumerCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") | ||
|
||
consumerCmd.Flags().StringP( | ||
"broker", | ||
"b", | ||
"wss://shinobi.brokers.kenshi.io", | ||
"Unchained broker to connect to", | ||
) | ||
} |
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package constants | ||
|
||
var Version = "0.11.7" | ||
var ProtocolVersion = "0.11.7" | ||
var Version = "0.11.8" | ||
var ProtocolVersion = "0.11.8" |
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
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,26 @@ | ||
package client | ||
|
||
import ( | ||
"github.com/KenshiTech/unchained/datasets" | ||
"github.com/KenshiTech/unchained/log" | ||
"github.com/gorilla/websocket" | ||
"github.com/vmihailenco/msgpack/v5" | ||
) | ||
|
||
func Consume(message []byte) { | ||
var packet datasets.BroadcastPacket | ||
err := msgpack.Unmarshal(message[1:], &packet) | ||
if err != nil { | ||
panic(err) | ||
} | ||
log.Logger. | ||
With("Validators", len(packet.Signers)). | ||
With("Asset", packet.Info.Asset). | ||
With("Block", packet.Info.Block). | ||
With("Price", packet.Info.Price.Text(10)). | ||
Info("Attestation") | ||
} | ||
|
||
func StartConsumer() { | ||
Client.WriteMessage(websocket.BinaryMessage, []byte{6}) | ||
} |
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,13 @@ | ||
package consumer | ||
|
||
import ( | ||
"github.com/KenshiTech/unchained/net/repository" | ||
"github.com/gorilla/websocket" | ||
) | ||
|
||
func Broadcast(message []byte) { | ||
repository.Consumers.Range(func(consumer *websocket.Conn, _ bool) bool { | ||
consumer.WriteMessage(websocket.BinaryMessage, message) | ||
return true | ||
}) | ||
} |
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,13 @@ | ||
package repository | ||
|
||
import ( | ||
"github.com/gorilla/websocket" | ||
"github.com/puzpuzpuz/xsync/v3" | ||
) | ||
|
||
// TODO: Do consumers need KOSK? | ||
var Consumers *xsync.MapOf[*websocket.Conn, bool] | ||
|
||
func init() { | ||
Consumers = xsync.NewMapOf[*websocket.Conn, bool]() | ||
} |
Oops, something went wrong.