utils

package
v0.0.0-...-3680e65 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2017 License: MIT Imports: 16 Imported by: 3

Documentation

Index

Constants

View Source
const (
	UINT32_LEN = 4
	UINT64_LEN = 8
)
View Source
const (
	MAX_TERM_BUMP = 20
	ALPHA_GROUP   = 1 // the group for recording server members, groups, peers etc
)

Variables

View Source
var ClientConn map[string]*grpc.ClientConn = map[string]*grpc.ClientConn{}
View Source
var ConnLock sync.Mutex = sync.Mutex{}
View Source
var RPCLock sync.Mutex = sync.Mutex{}
View Source
var RPCServers map[string]*grpc.Server = map[string]*grpc.Server{}

Functions

func AlphaNodes

func AlphaNodes(servers []string) []*spb.Host

func BytesU64

func BytesU64(bs []byte, offset int) uint64

func CommandSignData

func CommandSignData(group uint64, sender uint64, reqId uint64, data []byte) []byte

func ExecCommandSignData

func ExecCommandSignData(cmd *pb.CommandRequest) []byte

func ExpectedPlayers

func ExpectedPlayers(num int) int

func GRPCServerListen

func GRPCServerListen(addr string) error

func GenerateKey

func GenerateKey() ([]byte, []byte, error)

func GetBytes

func GetBytes(key interface{}) ([]byte, error)

func GetClientConn

func GetClientConn(addr string) (*grpc.ClientConn, error)

func GetClusterRPC

func GetClusterRPC(addr string) (spb.BFTRaftClient, error)

func GetGRPCServer

func GetGRPCServer(addr string) *grpc.Server

func HashData

func HashData(data []byte) uint64

func HashPublicKey

func HashPublicKey(key *rsa.PublicKey) uint64

func HashPublicKeyBytes

func HashPublicKeyBytes(keyData []byte) uint64

func LogHash

func LogHash(prevHash []byte, index uint64, funcId uint64, args []byte) ([]byte, crypto.Hash)

func MajorityResponse

func MajorityResponse(clients []*spb.BFTRaftClient, f func(client spb.BFTRaftClient) (interface{}, []byte)) interface{}

func NodesSignData

func NodesSignData(nodes []*pb.Host) []byte

func ParsePrivateKey

func ParsePrivateKey(data []byte) (*rsa.PrivateKey, error)

func ParsePublicKey

func ParsePublicKey(data []byte) (*rsa.PublicKey, error)

func PickMajority

func PickMajority(hashes []uint64) uint64

func PublicKeyFromPrivate

func PublicKeyFromPrivate(key *rsa.PrivateKey) *rsa.PublicKey

func SHA1Hash

func SHA1Hash(data []byte) ([]byte, crypto.Hash)

func Sign

func Sign(privateKey *rsa.PrivateKey, data []byte) []byte

func U32Bytes

func U32Bytes(t uint32) []byte

func U64Bytes

func U64Bytes(n uint64) []byte

func VerifySign

func VerifySign(publicKey *rsa.PublicKey, signature []byte, data []byte) error

Types

type FuncResult

type FuncResult struct {
	Result  interface{}
	Feature []byte
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL