作者 yangfu

区块链参数修改

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