bosnet / sebak

SEBAK, the next BOScoin Blockchain
https://devteam.blockchainos.org
GNU General Public License v3.0
44 stars 15 forks source link

Make checkpoint a struct #98

Closed Charleslee522 closed 6 years ago

Charleslee522 commented 6 years ago

Now, checkpoint type is string so when we want to use source or target, we have to call ParseCheckpoint method. And checkpoint is used frequently, performance is important. I think if we define the Checkpoint struct and define related methods then it would be helpful for both performance and code quality.

type Checkpoint struct {
  Source string
  Target string
}
leejames00 commented 6 years ago

If Checkpoint is struct, Source and Target types should be hash, not string.. am i right?

Charleslee522 commented 6 years ago

@leejames00 It would be better :)

anarcher commented 6 years ago

Maybe it can be another approach... How about it? But I am not sure that it makes to improve performance. ~_~

type Checkpoint struct {
    Subtracted string // or Hash
    Added string // or Hash 
}
outsideris commented 6 years ago

What is another approach? I didn't get it.

Charleslee522 commented 6 years ago

@outsideris I guess, the name of fields?

Charleslee522 commented 6 years ago

@anarcher If we use Checkpoint struct, we don't have to parse checkpoint string every time.

sconeman commented 6 years ago

It would be better to name them Source andTarget. Later, when we develop TC, we can implement other functions besides boscoin transactions.

anarcher commented 6 years ago

I confused that ‘Source’ as SourceCheckpoint :-)

My approach is same as yours :-) haha

anarcher commented 6 years ago
type Checkpoint struct {
    Hash string // Compound value: "<Subtracted>-<Added>"
    Subtracted string
    Added string
}
spikeekips commented 6 years ago

Resolved by #140