Skip to content
This repository has been archived by the owner on Nov 15, 2021. It is now read-only.

Commit

Permalink
fix for bug with assets with very large amounts
Browse files Browse the repository at this point in the history
  • Loading branch information
localhuman committed Sep 19, 2017
1 parent a1f7dd0 commit 7dc936f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion neo/Core/State/AssetState.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def Serialize(self, writer):
writer.WriteUInt256( self.AssetId)
writer.WriteByte(self.AssetType)
writer.WriteVarString(self.Name)
print("WILL WRITE ASSET STATE %s " % self.Amount.value)

if self.Amount.value > -1:
writer.WriteFixed8(self.Amount, unsigned=True)
else:
Expand Down
12 changes: 9 additions & 3 deletions neo/IO/BinaryReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ def ReadHashes(self, maximum=16):
items.append( ba.hex())
return items

def ReadFixed8(self):
fval = self.ReadInt64()
return Fixed8( fval )
def ReadFixed8(self, unsigned=False):


if unsigned:
fval = self.ReadUInt64()
else:
fval = self.ReadInt64()

return Fixed8(fval)
4 changes: 3 additions & 1 deletion neo/IO/BinaryWriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ def WriteHashes(self, arr):
# print("WRITING HASH %s " % ba)
self.WriteBytes(ba)

def WriteFixed8(self, value, unsigned=False):
if unsigned:
return self.WriteUInt64(int(value.value))

def WriteFixed8(self, value):
return self.WriteInt64(value.value)

0 comments on commit 7dc936f

Please sign in to comment.