From 12eefe1cc586233d304593ab7b23014daa4fc06e Mon Sep 17 00:00:00 2001 From: Luca Moser <moser.luca@gmail.com> Date: Thu, 16 Jan 2020 19:30:48 +0100 Subject: [PATCH] Updates to iota.go v1.0.0-beta.14 (#133) * updates to iota.go v1.0.0-beta.14 * Use trinary.Must.. Co-authored-by: Wolfgang Welz <welzwo@gmail.com> --- go.mod | 4 ++-- go.sum | 7 +++++-- packages/client/bundlefactory.go | 2 +- packages/model/meta_transaction/meta_transaction.go | 8 ++------ packages/model/value_transaction/value_transaction.go | 8 ++------ plugins/webapi/getTrytes/plugin.go | 6 +----- 6 files changed, 13 insertions(+), 22 deletions(-) diff --git a/go.mod b/go.mod index 989cd7ff..9209c986 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/googollee/go-socket.io v1.4.3-0.20191204093753-683f8725b6d0 github.com/gorilla/websocket v1.4.1 github.com/iotaledger/hive.go v0.0.0-20200110132858-ea86cdb9d91e - github.com/iotaledger/iota.go v1.0.0-beta.13 + github.com/iotaledger/iota.go v1.0.0-beta.14 github.com/labstack/echo v3.3.10+incompatible github.com/labstack/gommon v0.3.0 // indirect github.com/lucasb-eyer/go-colorful v1.0.3 // indirect @@ -23,7 +23,7 @@ require ( github.com/mattn/go-isatty v0.0.11 // indirect github.com/mattn/go-runewidth v0.0.7 // indirect github.com/pelletier/go-toml v1.6.0 // indirect - github.com/pkg/errors v0.8.1 + github.com/pkg/errors v0.9.1 github.com/rivo/tview v0.0.0-20191229165609-1ee8d9874dcf github.com/spf13/afero v1.2.2 // indirect github.com/spf13/cast v1.3.1 // indirect diff --git a/go.sum b/go.sum index 1ee1b7b4..3e2ecd23 100644 --- a/go.sum +++ b/go.sum @@ -22,6 +22,7 @@ github.com/beevik/ntp v0.2.0/go.mod h1:hIHWr+l3+/clUnF44zdK+CWW7fO8dR5cIylAQ76NR github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= +github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= @@ -118,8 +119,8 @@ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANyt github.com/iotaledger/hive.go v0.0.0-20200110132858-ea86cdb9d91e h1:bowQHvFQoUWPgxlF9cQRWDzREswR09HpihMiNX1q+AU= github.com/iotaledger/hive.go v0.0.0-20200110132858-ea86cdb9d91e/go.mod h1:obs07gqna53/Yw1ltzLsQzJBMyA6lGu7Fb/ltjqWMnQ= github.com/iotaledger/iota.go v1.0.0-beta.9/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= -github.com/iotaledger/iota.go v1.0.0-beta.13 h1:6m6JRcKtjTflU2PbjvDA9Tv6NTEJX1PijBDOkH9weQc= -github.com/iotaledger/iota.go v1.0.0-beta.13/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= +github.com/iotaledger/iota.go v1.0.0-beta.14 h1:Oeb28MfBuJEeXcGrLhTCJFtbsnc8y1u7xidsAmiOD5A= +github.com/iotaledger/iota.go v1.0.0-beta.14/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= @@ -180,6 +181,8 @@ github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCr github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= diff --git a/packages/client/bundlefactory.go b/packages/client/bundlefactory.go index e064d769..dc2d6534 100644 --- a/packages/client/bundlefactory.go +++ b/packages/client/bundlefactory.go @@ -37,7 +37,7 @@ func (bundleFactory *BundleFactory) AddOutput(address *Address, value int64, mes bundleFactory.outputs = append(bundleFactory.outputs, bundleFactoryOutputEntry{ address: address, value: value, - message: trinary.Pad(messageTrytes, value_transaction.SIGNATURE_MESSAGE_FRAGMENT_SIZE), + message: trinary.MustPad(messageTrytes, value_transaction.SIGNATURE_MESSAGE_FRAGMENT_SIZE), }) } else { bundleFactory.outputs = append(bundleFactory.outputs, bundleFactoryOutputEntry{ diff --git a/packages/model/meta_transaction/meta_transaction.go b/packages/model/meta_transaction/meta_transaction.go index d85160a6..1ed46144 100644 --- a/packages/model/meta_transaction/meta_transaction.go +++ b/packages/model/meta_transaction/meta_transaction.go @@ -53,11 +53,7 @@ func FromTrits(trits trinary.Trits) *MetaTransaction { } func FromBytes(bytes []byte) (result *MetaTransaction) { - trits, err := trinary.BytesToTrits(bytes) - if err != nil { - panic(err) - } - + trits := trinary.MustBytesToTrits(bytes) result = FromTrits(trits[:MARSHALED_TOTAL_SIZE]) result.bytes = bytes @@ -477,7 +473,7 @@ func (this *MetaTransaction) GetBytes() (result []byte) { defer this.bytesMutex.Unlock() this.hasherMutex.Lock() - this.bytes = trinary.TritsToBytes(this.trits) + this.bytes = trinary.MustTritsToBytes(this.trits) this.hasherMutex.Unlock() } else { this.bytesMutex.RUnlock() diff --git a/packages/model/value_transaction/value_transaction.go b/packages/model/value_transaction/value_transaction.go index b42a6473..393e6560 100644 --- a/packages/model/value_transaction/value_transaction.go +++ b/packages/model/value_transaction/value_transaction.go @@ -40,11 +40,7 @@ func FromMetaTransaction(metaTransaction *meta_transaction.MetaTransaction) *Val } func FromBytes(bytes []byte) (result *ValueTransaction) { - trits, err := trinary.BytesToTrits(bytes) - if err != nil { - panic(err) - } - + trits := trinary.MustBytesToTrits(bytes) result = &ValueTransaction{ MetaTransaction: meta_transaction.FromTrits(trits[:meta_transaction.MARSHALED_TOTAL_SIZE]), } @@ -180,7 +176,7 @@ func (this *ValueTransaction) SetTimestamp(timestamp uint) bool { this.timestamp = ×tamp this.BlockHasher() - copy(this.trits[TIMESTAMP_OFFSET:TIMESTAMP_END], trinary.PadTrits(trinary.IntToTrits(int64(timestamp)), TIMESTAMP_SIZE)[:TIMESTAMP_SIZE]) + copy(this.trits[TIMESTAMP_OFFSET:TIMESTAMP_END], trinary.MustPadTrits(trinary.IntToTrits(int64(timestamp)), TIMESTAMP_SIZE)[:TIMESTAMP_SIZE]) this.UnblockHasher() this.SetModified(true) diff --git a/plugins/webapi/getTrytes/plugin.go b/plugins/webapi/getTrytes/plugin.go index 8c9a8e25..b29b83fa 100644 --- a/plugins/webapi/getTrytes/plugin.go +++ b/plugins/webapi/getTrytes/plugin.go @@ -39,11 +39,7 @@ func getTrytes(c echo.Context) error { return requestFailed(c, err.Error()) } if tx != nil { - trytes, err := trinary.TritsToTrytes(tx.GetTrits()) - // Returns an error if len(tx.GetTrits())%3!=0 - if err != nil { - return requestFailed(c, err.Error()) - } + trytes := trinary.MustTritsToTrytes(tx.GetTrits()) result = append(result, trytes) } else { //tx not found -- GitLab