mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-07 06:36:46 +00:00

* [NOD-1225] Rename wire to domainmessage * [NOD-1225] Get rid of references to package wire in the code, and get rid of InvType
38 lines
891 B
Go
38 lines
891 B
Go
package integration
|
|
|
|
import (
|
|
"github.com/kaspanet/kaspad/domainmessage"
|
|
"github.com/kaspanet/kaspad/util"
|
|
|
|
rpcclient "github.com/kaspanet/kaspad/rpc/client"
|
|
)
|
|
|
|
type rpcClient struct {
|
|
*rpcclient.Client
|
|
onBlockAdded func(*domainmessage.BlockHeader)
|
|
}
|
|
|
|
func newRPCClient(rpcAddress string) (*rpcClient, error) {
|
|
client := &rpcClient{}
|
|
notificationHandlers := &rpcclient.NotificationHandlers{
|
|
OnFilteredBlockAdded: func(height uint64, header *domainmessage.BlockHeader, txs []*util.Tx) {
|
|
if client.onBlockAdded != nil {
|
|
client.onBlockAdded(header)
|
|
}
|
|
},
|
|
}
|
|
|
|
connConfig := &rpcclient.ConnConfig{
|
|
Host: rpcAddress,
|
|
Endpoint: "ws",
|
|
User: rpcUser,
|
|
Pass: rpcPass,
|
|
DisableTLS: true,
|
|
RequestTimeout: defaultTimeout,
|
|
}
|
|
|
|
var err error
|
|
client.Client, err = rpcclient.New(connConfig, notificationHandlers)
|
|
return client, err
|
|
}
|