diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000000000000000000000000000000000000..8d197c2fed30335f4f0793fbb4df893988df1fba --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,23 @@ +name: Publish Docker develop + +on: + push: + branches: + - develop + +jobs: + + build: + runs-on: ubuntu-latest + steps: + + - name: Check out code + uses: actions/checkout@master + + - name: Publish to registry + uses: elgohr/Publish-Docker-Github-Action@master + with: + name: iotagoshimmer/goshimmer + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + tags: "develop" diff --git a/dapps/valuetransfers/packages/tangle/tangle.go b/dapps/valuetransfers/packages/tangle/tangle.go index bc0fae742faf1ee51658588b1a7689100d61c584..cdd0c16c6206af4b113d4874b5634ae4a966be7e 100644 --- a/dapps/valuetransfers/packages/tangle/tangle.go +++ b/dapps/valuetransfers/packages/tangle/tangle.go @@ -166,8 +166,7 @@ func (tangle *Tangle) BranchManager() *branchmanager.BranchManager { } // LoadSnapshot creates a set of outputs in the value tangle, that are forming the genesis for future transactions. -func (tangle *Tangle) LoadSnapshot(snapshot Snapshot) { - // TODO: snapshot should also reflect the consumers of transactions +func (tangle *Tangle) LoadSnapshot(snapshot map[transaction.ID]map[address.Address][]*balance.Balance) { for transactionID, addressBalances := range snapshot { for outputAddress, balances := range addressBalances { input := NewOutput(outputAddress, transactionID, branchmanager.MasterBranchID, balances) @@ -235,7 +234,7 @@ func (tangle *Tangle) Fork(transactionID transaction.ID, conflictingInputs []tra } // trigger events + set result - tangle.Events.Fork.Trigger(cachedTransaction, cachedTransactionMetadata, cachedTargetBranch, conflictingInputs) + tangle.Events.Fork.Trigger(cachedTransaction, cachedTransactionMetadata) forked = true return @@ -1299,9 +1298,26 @@ func (tangle *Tangle) bookTransaction(cachedTransaction *transaction.CachedTrans // book transaction into target branch transactionMetadata.SetBranchID(targetBranch.ID()) + // create color for newly minted coins + mintedColor, _, err := balance.ColorFromBytes(transactionToBook.ID().Bytes()) + if err != nil { + panic(err) // this should never happen (a transaction id is always a valid color) + } + // book outputs into the target branch transactionToBook.Outputs().ForEach(func(address address.Address, balances []*balance.Balance) bool { - newOutput := NewOutput(address, transactionToBook.ID(), targetBranch.ID(), balances) + // create correctly colored balances (replacing color of newly minted coins with color of transaction id) + coloredBalances := make([]*balance.Balance, len(balances)) + for i, currentBalance := range balances { + if currentBalance.Color == balance.ColorNew { + coloredBalances[i] = balance.New(mintedColor, currentBalance.Value) + } else { + coloredBalances[i] = currentBalance + } + } + + // store output + newOutput := NewOutput(address, transactionToBook.ID(), targetBranch.ID(), coloredBalances) newOutput.setSolid(true) tangle.outputStorage.Store(newOutput).Release() @@ -1891,4 +1907,4 @@ func (stackEntry *valuePayloadPropagationStackEntry) Unwrap() (payload *payload. transactionMetadata = stackEntry.CachedTransactionMetadata.Unwrap() return -} +} \ No newline at end of file diff --git a/dapps/valuetransfers/packages/tangle/tangle_test.go b/dapps/valuetransfers/packages/tangle/tangle_test.go index 8f5c8d26c46ebfd34206e925cfae33883a725ad9..598a25c473cb68698f061a2cc90bb2e2018c2f56 100644 --- a/dapps/valuetransfers/packages/tangle/tangle_test.go +++ b/dapps/valuetransfers/packages/tangle/tangle_test.go @@ -1518,4 +1518,4 @@ func createDummyTransaction() *transaction.Transaction { }, }), ) -} +} \ No newline at end of file diff --git a/go.mod b/go.mod index 8f9efb1a924e256a9863f5104127c82741d9c1a2..4990d09cb225fece0e7473af4bff0765f53cc651 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/drand/kyber v1.0.1-0.20200331114745-30e90cc60f99 github.com/gobuffalo/packr/v2 v2.7.1 github.com/golang/protobuf v1.3.5 - github.com/google/go-cmp v0.4.0 + github.com/google/go-cmp v0.4.1 github.com/gorilla/websocket v1.4.1 github.com/iotaledger/hive.go v0.0.0-20200610104211-d603429af242 github.com/iotaledger/iota.go v1.0.0-beta.14 diff --git a/plugins/config/plugin.go b/plugins/config/plugin.go index ab43e6054cd4bfaff9aa9ceb373f80e75644b234..da882233e400356dfeffae261fb0e500f37453a4 100644 --- a/plugins/config/plugin.go +++ b/plugins/config/plugin.go @@ -3,6 +3,7 @@ package config import ( "fmt" "os" + "strings" "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/node" @@ -56,6 +57,12 @@ func init() { // It automatically reads in a single config file starting with "config" (can be changed via the --config CLI flag) // and ending with: .json, .toml, .yaml or .yml (in this sequence). func fetch(printConfig bool, ignoreSettingsAtPrint ...[]string) error { + // replace dots with underscores in env + dotReplacer := strings.NewReplacer(".", "_") + Node.SetEnvKeyReplacer(dotReplacer) + // read in ENV variables + Node.AutomaticEnv() + flag.Parse() err := parameter.LoadConfigFile(Node, *configDirPath, *configName, true, *skipConfigAvailable) if err != nil { diff --git a/plugins/webapi/info/plugin.go b/plugins/webapi/info/plugin.go index 2aa6d89cb1d5029458085958f5dcf6895eb2a162..6dc44a26c5fac5a606d5770a462b9ff75a874035 100644 --- a/plugins/webapi/info/plugin.go +++ b/plugins/webapi/info/plugin.go @@ -2,6 +2,7 @@ package info import ( "net/http" + "sort" "github.com/iotaledger/goshimmer/plugins/autopeering/local" "github.com/iotaledger/goshimmer/plugins/banner" @@ -60,16 +61,16 @@ func getInfo(c echo.Context) error { var enabledPlugins []string var disabledPlugins []string for pluginName, plugin := range node.GetPlugins() { - switch plugin.Status { - case node.Disabled: + if node.IsSkipped(plugin) { disabledPlugins = append(disabledPlugins, pluginName) - case node.Enabled: + } else { enabledPlugins = append(enabledPlugins, pluginName) - default: - continue } } + sort.Strings(enabledPlugins) + sort.Strings(disabledPlugins) + return c.JSON(http.StatusOK, Response{ Version: banner.AppVersion, Synced: sync.Synced(), @@ -89,11 +90,11 @@ type Response struct { // identity ID of the node encoded in base58 and truncated to its first 8 bytes IdentityID string `json:"identityID,omitempty"` // public key of the node encoded in base58 - PublicKey string `json:"publickey,omitempty"` + PublicKey string `json:"publicKey,omitempty"` // list of enabled plugins - EnabledPlugins []string `json:"enabledplugins,omitempty"` + EnabledPlugins []string `json:"enabledPlugins,omitempty"` // list if disabled plugins - DisabledPlugins []string `json:"disabledlugins,omitempty"` + DisabledPlugins []string `json:"disabledPlugins,omitempty"` // error of the response Error string `json:"error,omitempty"` } diff --git a/plugins/webapi/value/unspentoutputs/handler.go b/plugins/webapi/value/unspentoutputs/handler.go index 7b77c21544d9521d07317ccc090f99016215429c..11ac409e8258da28a22f06cc0efb7d117217e8a8 100644 --- a/plugins/webapi/value/unspentoutputs/handler.go +++ b/plugins/webapi/value/unspentoutputs/handler.go @@ -36,7 +36,6 @@ func Handler(c echo.Context) error { // TODO: don't do this in a for defer cachedTxMeta.Release() - // TODO: get inclusion state if output.ConsumerCount() == 0 { // iterate balances var b []utils.Balance diff --git a/plugins/webapi/value/utils/transaction_handler.go b/plugins/webapi/value/utils/transaction_handler.go index 3c50c38d3d5ffbd0ccb7dcb9647697c10959401d..1cd0ea409f40c42b52967bb4a081bd8e362b8f72 100644 --- a/plugins/webapi/value/utils/transaction_handler.go +++ b/plugins/webapi/value/utils/transaction_handler.go @@ -64,11 +64,11 @@ type Balance struct { // InclusionState represents the different states of an OutputID type InclusionState struct { - Confirmed bool `json:"confirmed,omitempty"` - Conflict bool `json:"conflict,omitempty"` - Liked bool `json:"liked,omitempty"` Solid bool `json:"solid,omitempty"` + Confirmed bool `json:"confirmed,omitempty"` Rejected bool `json:"rejected,omitempty"` + Liked bool `json:"liked,omitempty"` + Conflict bool `json:"conflict,omitempty"` Finalized bool `json:"finalized,omitempty"` Preferred bool `json:"preferred,omitempty"` }