作者 yangfu

区块链参数修改

... ... @@ -8,7 +8,7 @@ var (
// kafka topic log stash
TOPIC_LOG_STASH = "go_stash_dev" //"pushMessage"
// kafka topic up_block_chain
TOPIC_UP_BLOCK_CHAIN = "up_block_chain"
TOPIC_UP_BLOCK_CHAIN = "allied_creation_message"
// 是否启用日志收集 (本地不启用)
ENABLE_KAFKA_LOG = false
)
... ...
... ... @@ -14,24 +14,6 @@ import (
"testing"
)
//var priK = []byte(`-----BEGIN RSA PRIVATE KEY-----
//MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEA2H6x0D1mg5QbXfU7
//MZKltypRj+eZktPKIApyEqRsyLqe3sRSd1Eh+VqKlQ9QFI8dae3t0USWlVmyfIDM
//0ly85QIDAQABAkAPnKNJ9wOLfYSzs9l+66pTmROkovjqI6exw88SFRVbLCgM8maa
//GOWEP/nhZDlQYBKHUqG0/KsLkeyLGkE8N7JBAiEA8lM3npA3q+Kmhy+lmQbfHFPQ
//31OSkA+RaW/LPn0lP50CIQDktlF3iDk5kxnzgT/3lvvKhHInUh+pH5F19C6MymMD
//6QIgLxDct655MahnAdDOUCeWhBD/e7DmwZZUfu8Ywb1a070CIArsUjO9Q85mIiUp
//FR8EDP59GN6b43s2UMIraVW8DMKRAiEAnnMPbDsD2HsQbgmNNEqETUxYGVyO+p7w
//OZZReuOyvCM=
//-----END RSA PRIVATE KEY-----`)
//var pubPem = `-----BEGIN PUBLIC KEY-----
//MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANh+sdA9ZoOUG131OzGSpbcqUY/nmZLT
//yiAKchKkbMi6nt7EUndRIflaipUPUBSPHWnt7dFElpVZsnyAzNJcvOUCAwEAAQ==
//-----END PUBLIC KEY-----`
//var pubKey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANh+sdA9ZoOUG131OzGSpbcqUY/nmZLT\nyiAKchKkbMi6nt7EUndRIflaipUPUBSPHWnt7dFElpVZsnyAzNJcvOUCAwEAAQ=="
//
//var host = "http://allied-creation-gateway-dev.fjmaimaimai.com"
var priK = []byte(`-----BEGIN RSA PRIVATE KEY-----
MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEA2H6x0D1mg5QbXfU7
MZKltypRj+eZktPKIApyEqRsyLqe3sRSd1Eh+VqKlQ9QFI8dae3t0USWlVmyfIDM
... ... @@ -48,7 +30,7 @@ yiAKchKkbMi6nt7EUndRIflaipUPUBSPHWnt7dFElpVZsnyAzNJcvOUCAwEAAQ==
-----END PUBLIC KEY-----`
var pubKey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANh+sdA9ZoOUG131OzGSpbcqUY/nmZLTyiAKchKkbMi6nt7EUndRIflaipUPUBSPHWnt7dFElpVZsnyAzNJcvOUCAwEAAQ=="
var host = "http://101.34.29.149:9092/test"
var host = "https://shangchain.fjmaimaimai.com/prod" //"http://101.34.29.149:9092/test"
func TestSignature(t *testing.T) {
options := NewUpToChainOptions("table", "1", "149848948").WithDesc("desc")
... ... @@ -145,7 +127,7 @@ func TestBSNBlockChain_GetToken(t *testing.T) {
}
options := &GetTokenRequest{
Type: 1,
TsTxId: "54df75d3bead65d144a1123d1f18af8bb4db65420c5c449631e9a93b81fcdb93",
TsTxId: "b2e4b906b5ac7952d6b1adcc05681dc6aef5386b07c05e9cdc9ab9d565c17dd4",
ShowValue: true,
}
token, err := bc.GetToken(options)
... ...
... ... @@ -16,6 +16,6 @@ yiAKchKkbMi6nt7EUndRIflaipUPUBSPHWnt7dFElpVZsnyAzNJcvOUCAwEAAQ==
-----END PUBLIC KEY-----`
var PubKey = "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANh+sdA9ZoOUG131OzGSpbcqUY/nmZLTyiAKchKkbMi6nt7EUndRIflaipUPUBSPHWnt7dFElpVZsnyAzNJcvOUCAwEAAQ=="
var Host = "http://101.34.29.149:9092/test"
var Host = "https://shangchain.fjmaimaimai.com/prod" //"http://101.34.29.149:9092/test"
var BlockBrowserAddress = "http://101.34.29.149/browser"
var BlockBrowserAddress = "https://shangchain.fjmaimaimai.com" //"http://101.34.29.149/browser"
... ...
... ... @@ -12,7 +12,7 @@ import (
func SetUp() {
go func() {
q := kq.MustNewQueue(NewConfig(constant.TOPIC_UP_BLOCK_CHAIN, constant.TOPIC_UP_BLOCK_CHAIN, 2), kq.WithHandle(UpToChainHandler))
q := kq.MustNewQueue(NewConfig(constant.TOPIC_UP_BLOCK_CHAIN, constant.TOPIC_UP_BLOCK_CHAIN, 2), kq.WithHandle(FilterTopicHandler("up_block_chain", UpToChainHandler)))
defer func() {
q.Stop()
log.Logger.Info(fmt.Sprintf("goqueue:%v stop!", constant.TOPIC_UP_BLOCK_CHAIN))
... ...
package goqueue
import (
rawjson "encoding/json"
"fmt"
"github.com/linmadan/egglib-go/utils/json"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-user/pkg/application/blockChain/command"
... ... @@ -19,3 +20,22 @@ func UpToChainHandler(k, v string) error {
_, err = blockChainService.UpChain(upChainCommand)
return err
}
func FilterTopicHandler(topic string, handler func(string, string) error) func(string, string) error {
return func(k string, v string) error {
raw := &RawData{}
err := json.UnmarshalFromString(v, raw)
if err != nil {
return err
}
if raw.Topic != topic {
return nil
}
return handler(k, string(raw.Data))
}
}
type RawData struct {
Topic string `json:"topic"`
Data rawjson.RawMessage `json:"data"`
}
... ...