func GetLocalNonce() (nonce *mine.Uint256, err error) {
	localKey.RLock()
	if localKey.nodeNonce != nil {
		nonce = new(mine.Uint256)
		*nonce = *localKey.nodeNonce
	} else {
		err = ErrNilField
	}
	localKey.RUnlock()
	return
}
GetLocalNonce gets current node nonce copy.
package kms
import (
	"errors"
	"sync"
	"github.com/SQLess/SQLess/crypto/asymmetric"
	"github.com/SQLess/SQLess/crypto/hash"
	mine "github.com/SQLess/SQLess/pow/cpuminer"
	"github.com/SQLess/SQLess/proto"
)
type LocalKeyStore struct {
	isSet     bool
	private   *asymmetric.PrivateKey
	public    *asymmetric.PublicKey
	nodeID    []byte
	nodeNonce *mine.Uint256
	sync.RWMutex
}
var (
	localKey *LocalKeyStore
	once     sync.Once
)
var (
	ErrNilField = errors.New("local field is nil")
)
func init() {
	initLocalKeyStore()
}
func initLocalKeyStore() {
	once.Do(func() {
		localKey = &LocalKeyStore{
			isSet:     false,
			private:   nil,
			public:    nil,
			nodeID:    nil,
			nodeNonce: nil,
		}
	})
}
func ResetLocalKeyStore() {
	localKey = &LocalKeyStore{
		isSet:     false,
		private:   nil,
		public:    nil,
		nodeID:    nil,
		nodeNonce: nil,
	}
}
func SetLocalKeyPair(private *asymmetric.PrivateKey, public *asymmetric.PublicKey) {
	localKey.Lock()
	defer localKey.Unlock()
	if localKey.isSet {
		return
	}
	localKey.isSet = true
	localKey.private = private
	localKey.public = public
}
func SetLocalNodeIDNonce(rawNodeID []byte, nonce *mine.Uint256) {
	localKey.Lock()
	defer localKey.Unlock()
	localKey.nodeID = make([]byte, len(rawNodeID))
	copy(localKey.nodeID, rawNodeID)
	if nonce != nil {
		localKey.nodeNonce = new(mine.Uint256)
		*localKey.nodeNonce = *nonce
	}
}
func GetLocalNodeID() (rawNodeID proto.NodeID, err error) {
	var rawNodeIDBytes []byte
	if rawNodeIDBytes, err = GetLocalNodeIDBytes(); err != nil {
		return
	}
	var h *hash.Hash
	if h, err = hash.NewHash(rawNodeIDBytes); err != nil {
		return
	}
	rawNodeID = proto.NodeID(h.String())
	return
}
func GetLocalNodeIDBytes() (rawNodeID []byte, err error) {
	localKey.RLock()
	if localKey.nodeID != nil {
		rawNodeID = make([]byte, len(localKey.nodeID))
		copy(rawNodeID, localKey.nodeID)
	} else {
		err = ErrNilField
	}
	localKey.RUnlock()
	return
}