Skip to content
Snippets Groups Projects
Commit 584018a1 authored by Hans Moog's avatar Hans Moog
Browse files

Merge branch 'develop' into develop.mergeBinary

parents 22ce9ccc b5269834
No related branches found
No related tags found
No related merge requests found
......@@ -15,6 +15,8 @@ require (
github.com/gorilla/websocket v1.4.1
github.com/iotaledger/hive.go v0.0.0-20200219224037-2d5f5238c0de
github.com/iotaledger/iota.go v1.0.0-beta.14
github.com/kr/pretty v0.2.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/labstack/echo v3.3.10+incompatible
github.com/labstack/gommon v0.3.0 // indirect
github.com/magiconair/properties v1.8.1
......@@ -26,22 +28,21 @@ require (
github.com/pelletier/go-toml v1.6.0 // indirect
github.com/pkg/errors v0.9.1
github.com/rogpeppe/go-internal v1.5.2 // indirect
github.com/sergi/go-diff v1.1.0 // indirect
github.com/spf13/afero v1.2.2 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.6.1
github.com/stretchr/objx v0.2.0 // indirect
github.com/stretchr/testify v1.4.0
github.com/valyala/fasttemplate v1.1.0 // indirect
go.uber.org/atomic v1.5.1
go.uber.org/zap v1.13.0
golang.org/dl v0.0.0-20200212233958-09d79dcf4807 // indirect
golang.org/x/crypto v0.0.0-20200128174031-69ecbb4d6d5d
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553
golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9 // indirect
golang.org/x/text v0.3.2 // indirect
golang.org/x/crypto v0.0.0-20200214034016-1d94cc7ab1c6
golang.org/x/net v0.0.0-20200202094626-16171245cfb2
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4 // indirect
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7 // indirect
gopkg.in/ini.v1 v1.51.1 // indirect
gopkg.in/src-d/go-git.v4 v4.13.1
gopkg.in/yaml.v2 v2.2.7 // indirect
)
This diff is collapsed.
......@@ -56,8 +56,11 @@ func FromTrits(trits trinary.Trits) *MetaTransaction {
}
}
func FromBytes(bytes []byte) (result *MetaTransaction) {
func FromBytes(bytes []byte) (result *MetaTransaction, err error) {
trits := trinary.MustBytesToTrits(bytes)
if len(trits) < MARSHALED_TOTAL_SIZE {
return nil, fmt.Errorf("invalid size %v", len(trits))
}
result = FromTrits(trits[:MARSHALED_TOTAL_SIZE])
result.bytes = bytes
......
......
......@@ -47,7 +47,9 @@ func TestMetaTransaction_SettersGetters(t *testing.T) {
assert.Equal(t, tx.IsHead(), head)
assert.Equal(t, tx.IsTail(), tail)
assert.Equal(t, tx.GetTransactionType(), transactionType)
assert.Equal(t, tx.GetHash(), FromBytes(tx.GetBytes()).GetHash())
metaTx, err := FromBytes(tx.GetBytes())
require.NoError(t, err)
assert.Equal(t, tx.GetHash(), metaTx.GetHash())
assert.EqualValues(t, "KKDVHBENVLQUNO9WOWWEJPBBHUSYRSRKIMZWCFCDB9RYZKYWLAYWRIBRQETBFKE9TIVWQPCKFWAMCLCAV", tx.GetHash())
}
......
......
......@@ -41,7 +41,7 @@ func configureLocal() *peer.Local {
}
}
if !externalIP.IsGlobalUnicast() {
log.Fatalf("IP is not a global unicast address: %s", externalIP.String())
log.Warnf("IP is not a global unicast address: %s", externalIP.String())
}
peeringPort := strconv.Itoa(config.NodeConfig.GetInt(CFG_PORT))
......
......
......@@ -6,7 +6,6 @@ import (
"time"
"github.com/iotaledger/goshimmer/plugins/config"
"github.com/iotaledger/goshimmer/plugins/tangle_old"
"golang.org/x/net/context"
"github.com/iotaledger/goshimmer/packages/model/value_transaction"
......
......
......@@ -9,21 +9,29 @@ import (
"encoding/json"
"fmt"
"net"
"os"
"path/filepath"
"runtime"
"time"
"github.com/iotaledger/goshimmer/packages/shutdown"
"github.com/iotaledger/goshimmer/plugins/autopeering/local"
"github.com/iotaledger/goshimmer/plugins/cli"
"github.com/iotaledger/goshimmer/plugins/config"
"github.com/iotaledger/hive.go/daemon"
"github.com/iotaledger/hive.go/events"
"github.com/iotaledger/hive.go/logger"
"github.com/iotaledger/hive.go/node"
"github.com/iotaledger/hive.go/workerpool"
"github.com/iotaledger/goshimmer/packages/shutdown"
"github.com/iotaledger/goshimmer/plugins/autopeering/local"
"github.com/iotaledger/goshimmer/plugins/config"
"gopkg.in/src-d/go-git.v4"
)
type logMessage struct {
Version string `json:"version"`
GitHead string `json:"gitHead,omitempty"`
GitBranch string `json:"gitBranch,omitempty"`
NodeId string `json:"nodeId"`
Level string `json:"level"`
Name string `json:"name"`
......@@ -42,6 +50,8 @@ var (
log *logger.Logger
conn net.Conn
myID string
myGitHead string
myGitBranch string
workerPool *workerpool.WorkerPool
)
......@@ -64,6 +74,8 @@ func configure(plugin *node.Plugin) {
myID = hex.EncodeToString(local.GetInstance().ID().Bytes())
}
getGitInfo()
workerPool = workerpool.New(func(task workerpool.Task) {
sendLogMsg(task.Param(0).(logger.Level), task.Param(1).(string), task.Param(2).(string))
......@@ -88,7 +100,54 @@ func run(plugin *node.Plugin) {
}
func sendLogMsg(level logger.Level, name string, msg string) {
m := logMessage{myID, level.CapitalString(), name, msg, time.Now()}
m := logMessage{
cli.AppVersion,
myGitHead,
myGitBranch,
myID,
level.CapitalString(),
name,
msg,
time.Now(),
}
b, _ := json.Marshal(m)
fmt.Fprint(conn, string(b))
}
func getGitInfo() {
r, err := git.PlainOpen(getGitDir())
if err != nil {
log.Debug("Could not open Git repo.")
return
}
// extract git branch and head
if h, err := r.Head(); err == nil {
myGitBranch = h.Name().String()
myGitHead = h.Hash().String()
}
}
func getGitDir() string {
var gitDir string
// this is valid when running an executable, when using "go run" this is a temp path
if ex, err := os.Executable(); err == nil {
temp := filepath.Join(filepath.Dir(ex), ".git")
if _, err := os.Stat(temp); err == nil {
gitDir = temp
}
}
// when running "go run" from the same directory
if gitDir == "" {
if wd, err := os.Getwd(); err == nil {
temp := filepath.Join(wd, ".git")
if _, err := os.Stat(temp); err == nil {
gitDir = temp
}
}
}
return gitDir
}
......@@ -13,7 +13,7 @@ services:
source: elasticsearch
target: /usr/share/elasticsearch/data
environment:
ES_JAVA_OPTS: "-Xmx256m -Xms256m"
ES_JAVA_OPTS: "-Xmx2g -Xms2g"
# Use single node discovery in order to disable production mode and avoid bootstrap checks
# see https://www.elastic.co/guide/en/elasticsearch/reference/current/bootstrap-checks.html
discovery.type: single-node
......@@ -35,7 +35,7 @@ services:
ports:
- "5213:5213/udp"
environment:
LS_JAVA_OPTS: "-Xmx256m -Xms256m"
LS_JAVA_OPTS: "-Xmx1g -Xms1g"
networks:
- elk
depends_on:
......
......
......@@ -8,7 +8,6 @@ import (
"github.com/iotaledger/goshimmer/packages/model/meta_transaction"
"github.com/iotaledger/goshimmer/packages/model/value_transaction"
"github.com/iotaledger/goshimmer/plugins/autopeering/local"
"github.com/iotaledger/goshimmer/plugins/tipselection"
"github.com/iotaledger/goshimmer/plugins/webapi"
"github.com/iotaledger/hive.go/logger"
"github.com/iotaledger/hive.go/node"
......@@ -64,8 +63,8 @@ func broadcastData(c echo.Context) error {
tx.SetAddress(request.Address)
tx.SetSignatureMessageFragment(trytes)
tx.SetValue(0)
tx.SetBranchTransactionHash(tipselection.GetRandomTip())
tx.SetTrunkTransactionHash(tipselection.GetRandomTip(tx.GetBranchTransactionHash()))
tx.SetBranchTransactionHash(tipselectionn.GetRandomTip())
tx.SetTrunkTransactionHash(tipselectionn.GetRandomTip(tx.GetBranchTransactionHash()))
tx.SetTimestamp(uint(time.Now().Unix()))
if err := tx.DoProofOfWork(meta_transaction.MIN_WEIGHT_MAGNITUDE); err != nil {
log.Warnf("PoW failed: %s", err)
......
......
......@@ -4,7 +4,6 @@ import (
"fmt"
"net/http"
"github.com/iotaledger/goshimmer/plugins/tangle_old"
"github.com/iotaledger/goshimmer/plugins/webapi"
"github.com/iotaledger/hive.go/logger"
"github.com/iotaledger/hive.go/node"
......
......
......@@ -4,7 +4,6 @@ import (
"fmt"
"net/http"
"github.com/iotaledger/goshimmer/plugins/tangle_old"
"github.com/iotaledger/goshimmer/plugins/webapi"
"github.com/iotaledger/hive.go/logger"
"github.com/iotaledger/hive.go/node"
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment