kaspad/integration/rpc_test.go
Ori Newman 8e170cf327
[NOD-1225] Rename wire to domainmessage and get rid of InvType (#853)
* [NOD-1225] Rename wire to domainmessage

* [NOD-1225] Get rid of references to package wire in the code, and get rid of InvType
2020-08-09 12:39:15 +03:00

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
}