From 56db958a59ee5f622e28cf77ca9ea7386bce7c36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sad=C4=B1k=20S=C3=BCnb=C3=BCl?= <109942759+SadikSunbul@users.noreply.github.com> Date: Thu, 20 Jun 2024 13:42:29 +0300 Subject: [PATCH] =?UTF-8?q?yorum=20sat=C4=B1rlr=C4=B1=20eklendi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tmp/blocks/000000.vlog | Bin 2666 -> 4042 bytes tmp/blocks/000008.sst | Bin 554 -> 0 bytes tmp/blocks/000012.sst | Bin 0 -> 681 bytes tmp/blocks/MANIFEST | Bin 434 -> 646 bytes tmp/wallets.data | Bin 1223 -> 1654 bytes wallet/wallet.go | 1 + wallet/wallets.go | 63 ++++++++++++++++++++++------------------- 7 files changed, 35 insertions(+), 29 deletions(-) delete mode 100644 tmp/blocks/000008.sst create mode 100644 tmp/blocks/000012.sst diff --git a/tmp/blocks/000000.vlog b/tmp/blocks/000000.vlog index 3b1ee5f598f8c38e3f659f6362a23028e8c0ffaf..0b5801d6470166309f37d65dcd7002f15cb7de50 100644 GIT binary patch delta 574 zcmaDQa!P(f7MB$R1A_(w1LGec4F(QCl6&Ez>)Xz;_ODp=RmxBG&ChF~* zUl;H&;Xed?+x(Z^htYHW{~ksKLRuIZ85N!#yRh~CcfUzjcQe@CnzljlM)Jg(Q}dz> zjDF3Lo9=Oeb8;T1iZl~*VooLlBNL+tBWrPDN@g|#kOdZFnC!!;%=wq?<~4@tQ`cus z-pC@Y`i+piLDz3ePyWcF;_%H<KE-(zhRLY`zFFlK9+l~SDItla<*t4~ zzQ*~HW@d%JSX3YsAdG)`e}7{5J$26pPyp(FA>{wXJnOxIfdmRMrpXK0W!S$M8m?EE GB?|zsQ}Rpz delta 7 OcmX>l|4L*-78d{x7Xu6c diff --git a/tmp/blocks/000008.sst b/tmp/blocks/000008.sst deleted file mode 100644 index bcb0843490fe5c73377bbe7a0b6ae26b833f29c2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 554 zcmZQzV9;RT{|^KV3^E){Tb@367JuyKkqz%2N#1ol82aJzO4Ge(`T9=Qz6GfPf?rMy zP{3rzz`!caz|5e^zz-6tI`XRR;*Rf^p5`4~HSO6Z|IRy$CB80R@49ZaWLFbJ^Z!2x z-8KviOr;D=3~FHAj@tZJ)pzfS*xvA?_|}r`887!|q`u#`J@)RcJHgsQu~6;*5Zbwc zHafty*IRvM6xCIKrogr9$T5ZZpv5~o=h+`EzFAk2!^LmV1J(Wmq1~2&f&DPh2obRD z`xKKBQ_@q56f;s2Q=p2!gZu;mS_}+a4nQVE@n0;8e?nCPDWGEZnLwHgWHO^xP6meM zKz9RW;Yz~cN)TZSQo5RM@MHM1_8Gq2<_0_`mU00l$5Z~y=R diff --git a/tmp/blocks/000012.sst b/tmp/blocks/000012.sst new file mode 100644 index 0000000000000000000000000000000000000000..9e9955486ba14395f0007a55c87667bbe5f97256 GIT binary patch literal 681 zcmZQzV9;RT{|^KV4BQJBUEg+&wSUE`uTp-hA6LKnxTaaCHc@Zi{JMaL2_Q8<@Xd(< z3Ye@I7`U<+m>AR;_(4K4986oDK6n;??BGo; zq1}#wfmIr=-BG6M$g8%CJHB6fns;#3v}c?AJMS!(__}z#>$=sFT}@E!e-PSj7#NsJ z;o2Lt`LC+)-V?FC;YabUCEGJz?$1blzi)f&-CK8pwS{7#+W#T6a|2!M0N1|X&}V06 z#=YAfs)uw>G)y(T$IHKG#fn?MZu{hN>)maj*c!)j!uq_uC87{wxeT^r?ab@ zqqAd>hoiHTqbpd>F)}dS(a{-*LBK5xs2mJDGqQjhfVu;L+JTglqo*rSoui|zt&)xs R&;p+Q+@U{Q| literal 0 HcmV?d00001 diff --git a/tmp/blocks/MANIFEST b/tmp/blocks/MANIFEST index 4bb0215159bcaf1753c304c36c50aad0054d939e..9cceafe08e329d0707ba493533989ea26f80860a 100644 GIT binary patch delta 221 zcmdnQ+{U_L6JtFC1B04G|8;9F6%I}%g_U}T%Ee+QCqC%$yR+%dxuqpZr@t9@Z*RCP zV_RnZWtTZnwMq0ejt(w04lW5sC54%H)uxurdvIaOQg`#td)tNV<$t7S&z%+9di5&&NxmY+j1sH)OhX5nUCZDMJcSnM(X1S(ae8QHJ z*e$kERX%Pq$STRq93G%mJRqz3lHWQ{HGIJ!e7EA`*RWDmyxrY+ N8PF1LuvJ_Fi~!6_PhJ23 delta 7 OcmZo;-Nd|M6C(f$$^xVS diff --git a/tmp/wallets.data b/tmp/wallets.data index 308319188887dd70db5bc004f09e43fbcc2585b5..7924cd696363e83eba8a9d9df309066236a44504 100644 GIT binary patch delta 257 zcmX@k`Hg473r6P2;>?bdwHRxdSk6se!FXh{G|OsbB}12V%b@(AWZ%e=VA`}!wVv%(d{a-V>&22n|E~In545ye&MZH)+Li&RMt$4-3F|_4 z-OCo?Hc5T7KtUrj_O#5FWxWBr3oB}01V3Y7biitp4w6*_?V0$}5#;8{IZUe=82}N0 BW>o+H delta 40 ycmV+@0N4Na495wO=m7$g#soo=Dgk@~10R#90mPHa1*?(iL6cYm!;@?Rs{sH*whwRs diff --git a/wallet/wallet.go b/wallet/wallet.go index 93e233b..5fb3d58 100644 --- a/wallet/wallet.go +++ b/wallet/wallet.go @@ -19,6 +19,7 @@ type Wallet struct { PublickKey []byte } +// NewKeyPair fonksiyonu, bir private ve public key olusturur func NewKeyPair() (ecdsa.PrivateKey, []byte) { curve := elliptic.P256() //kullanıcagımız eliptik tipi burdakı sıfreler 256 byte olur diff --git a/wallet/wallets.go b/wallet/wallets.go index 5c2695c..53fe42a 100644 --- a/wallet/wallets.go +++ b/wallet/wallets.go @@ -15,69 +15,74 @@ type Wallets struct { Wallets map[string]*Wallet } +// CreateWallets fonksiyonu, bir Wallets nesnesi olusturur func CreateWallets() (*Wallets, error) { - wallets := Wallets{} - wallets.Wallets = make(map[string]*Wallet) + wallets := Wallets{} // wallet nesnesi olusturulur + wallets.Wallets = make(map[string]*Wallet) // wallet nesnesi olusturulur - err := wallets.LoadFile() + err := wallets.LoadFile() // wallets dosyası okunur - return &wallets, err + return &wallets, err // wallets nesnesi döndürülür } +// GetWallet fonksiyonu, bir Wallet nesnesini döndürür func (ws *Wallets) GetWallet(address string) Wallet { - return *ws.Wallets[address] + return *ws.Wallets[address] // wallet nesnesi döndürülür } +// AddWallet fonksiyonu, bir Wallet nesnesi ekler func (ws *Wallets) AddWallet() string { - wallet := MakeWallet() - address := fmt.Sprintf("%s", wallet.Address()) - ws.Wallets[address] = wallet - return address + wallet := MakeWallet() // wallet nesnesi olusturulur + address := fmt.Sprintf("%s", wallet.Address()) // wallet adresi stringe dönüştürülür + ws.Wallets[address] = wallet // wallet nesnesi eklenir + return address // wallet adresi döndürülür } +// GetAllAddress fonksiyonu, tüm wallet adreslerini döndürür func (ws *Wallets) GetAllAddress() []string { - var addresses []string - for address := range ws.Wallets { - addresses = append(addresses, address) + var addresses []string // adreslerin listesi olusturulur + for address := range ws.Wallets { // tüm wallet adreslerini döndürür + addresses = append(addresses, address) // adreslerin listesi eklenir } - return addresses + return addresses // adreslerin listesi döndürülür } +// LoadFile fonksiyonu, dosya okunur func (ws *Wallets) LoadFile() error { - if _, err := os.Stat(walletFile); os.IsNotExist(err) { //dosya varmı - return err + if _, err := os.Stat(walletFile); os.IsNotExist(err) { // dosya yoksa + return err // hata döndürür } - var wallets Wallets + var wallets Wallets // wallet nesnesi olusturulur - fileContent, err := os.ReadFile(walletFile) + fileContent, err := os.ReadFile(walletFile) // dosya okunur if err != nil { log.Panic(err) - } - gob.Register(elliptic.P256()) - decoder := gob.NewDecoder(bytes.NewReader(fileContent)) - err = decoder.Decode(&wallets) + } // hata döndürür + gob.Register(elliptic.P256()) // elliptic nesnesi olusturulur + decoder := gob.NewDecoder(bytes.NewReader(fileContent)) // decoder nesnesi olusturulur + err = decoder.Decode(&wallets) // decoder ile dosya okunur if err != nil { - fmt.Println("hataa decode de") - log.Panic(err) + log.Panic(err) // hata döndürür } - ws.Wallets = wallets.Wallets + ws.Wallets = wallets.Wallets // wallet nesnesi olusturulur - return nil + return nil // hata yok } +// SaveFile fonksiyonu, dosya kaydedilir func (ws *Wallets) SaveFile() { var content bytes.Buffer - gob.Register(elliptic.P256()) - encoder := gob.NewEncoder(&content) - err := encoder.Encode(ws) + gob.Register(elliptic.P256()) // elliptic nesnesi olusturulur + encoder := gob.NewEncoder(&content) // encoder nesnesi oluşturulur + err := encoder.Encode(ws) // encoder ile dosya kaydedilir if err != nil { log.Panic(err) } - err = os.WriteFile(walletFile, content.Bytes(), 0644) + err = os.WriteFile(walletFile, content.Bytes(), 0644) // dosya kaydedilir if err != nil { log.Panic(err) }